Skip to content

Commit 5e8812d

Browse files
authored
Merge pull request #34 from code2docs-ai/ups216/update-workflow-runs
Update workflow_runs.json at the end of the workflow
2 parents bf9948f + dfff19f commit 5e8812d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.github/workflows/create-repo.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,12 @@ jobs:
121121
git add .
122122
git commit -m "Generate document for ${{ env.repoName }}"
123123
git push https://code2docs-ai:${{ secrets.MY_PAT }}@github.com/code2docs-ai/${{ env.docs_repo_name }}.git main
124-
124+
125+
- name: Update workflow run state
126+
run: |
127+
cd code2docs-ai-core
128+
workflow_run=$(jq --arg id "${{ github.run_id }}" --arg status "completed" --arg completed_at "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" 'map(if .id == $id then .status = $status | .completed_at = $completed_at else . end)' workflow_runs.json)
129+
echo "$workflow_run" > workflow_runs.json
130+
git add workflow_runs.json
131+
git commit -m "Update workflow_runs.json with completed status"
132+
git push https://code2docs-ai:${{ secrets.MY_PAT }}@github.com/${{ github.repository }}.git main

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ The workflow now includes functionality to store the state of workflow runs in a
8686
- Workflow run created time
8787

8888
The `workflow_runs.json` file is created or updated during each workflow run, and the new record of the current workflow run is added to the top of the existing content of the file. The file is then committed and pushed to the repository.
89+
90+
### Updating Workflow Run State
91+
92+
The workflow now includes a step at the end to update the `workflow_runs.json` file with the status set to 'completed' and the 'completed_at' field with the current time. This ensures that the workflow run state is accurately recorded and updated.

0 commit comments

Comments
 (0)