Skip to content

Commit dfff19f

Browse files
committed
Update workflow_runs.json at the end of the workflow
Related to #33 Add a step to update the workflow run state in `.github/workflows/create-repo.yml`. * **Update workflow run state** - Add a new step at the end of the workflow to update the `workflow_runs.json` file. - Update the status to 'completed' and add the 'completed_at' field with the current time. - Commit and push the updated `workflow_runs.json` file to the repository. * **Documentation** - Add a note in `README.md` about updating the `workflow_runs.json` file at the end of the workflow. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/code2docs-ai/code2docs-ai-core/issues/33?shareId=XXXX-XXXX-XXXX-XXXX).
1 parent bf9948f commit dfff19f

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)