Skip to content

Commit a39e110

Browse files
authored
Merge pull request #28 from code2docs-ai/ups216/add-workflow-runs-json
Add functionality to store workflow runs state in JSON file
2 parents 0c1258f + 9871ea1 commit a39e110

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

.github/workflows/create-repo.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,24 @@ jobs:
105105
git add .
106106
git commit -m "Generate document for ${{ env.repoName }}"
107107
git push https://code2docs-ai:${{ secrets.MY_PAT }}@github.com/code2docs-ai/${{ env.docs_repo_name }}.git main
108+
109+
- name: Clone the current repository
110+
run: |
111+
git clone https://github.com/${{ github.repository }}.git
112+
cd ${{ github.repository }}
113+
114+
- name: Create or update workflow_runs.json
115+
run: |
116+
if [ ! -f workflow_runs.json ]; then
117+
echo "[]" > workflow_runs.json
118+
fi
119+
workflow_run=$(jq -n --arg id "${{ github.run_id }}" --arg repoUrl "${{ github.event.inputs.repoUrl }}" --arg branchName "${{ github.event.inputs.branchName }}" --arg docs_repo_name "${{ env.docs_repo_name }}" --arg status "${{ job.status }}" --arg conclusion "${{ job.conclusion }}" --arg created_at "${{ github.event.created_at }}" '{id: $id, repoUrl: $repoUrl, branchName: $branchName, docs_repo_name: $docs_repo_name, status: $status, conclusion: $conclusion, created_at: $created_at}')
120+
jq ". += [$workflow_run]" workflow_runs.json > tmp.json && mv tmp.json workflow_runs.json
121+
122+
- name: Commit and push workflow_runs.json
123+
run: |
124+
git config --global user.email "[email protected]"
125+
git config --global user.name "code2docs-ai agent"
126+
git add workflow_runs.json
127+
git commit -m "Update workflow_runs.json"
128+
git push https://code2docs-ai:${{ secrets.MY_PAT }}@github.com/${{ github.repository }}.git main

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ The workflow now includes additional steps to activate the python environment, r
7676
aise-cli repo parse-repo --repo_path aise-cli repo parse-repo --repo_name <source_repo absolute>
7777
```
7878

79-
### Created by code2repo ai
79+
### Storing Workflow Run State
8080

81-
This repository was created by code2repo ai.
81+
The workflow now includes functionality to store the state of workflow runs in a JSON file named `workflow_runs.json`. This file includes the following values for each workflow run:
82+
- Workflow run id
83+
- `repoUrl` and `branchName` from the input parameters
84+
- `docs_repo_name`
85+
- Current status and conclusion
86+
- Workflow run created time
87+
88+
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 existing content of the file. The file is then committed and pushed to the repository.

0 commit comments

Comments
 (0)