Skip to content

Commit b11f66f

Browse files
authored
chore(github-actions): update contributor and project sync workflows (#869)
* chore(github-actions): updated sync contributor and project workflow to create pull request * update sync contributor and project roadmap to auto merge pr
1 parent 6a544fa commit b11f66f

File tree

2 files changed

+65
-7
lines changed

2 files changed

+65
-7
lines changed

.github/workflows/sync-contributors.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,42 @@ jobs:
4646
fs.writeFileSync('community.json', JSON.stringify(data, null, 2));
4747
4848
- name: Commit changes
49-
env:
50-
GITHUB_APP_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
5149
run: |
5250
git config user.name "the-json-schema-bot[bot]"
5351
git config user.email "the-json-schema-bot[bot]@users.noreply.github.com"
5452
git add community.json
55-
git diff --quiet && git diff --staged --quiet || (git commit -m "chore(community): update community.json" && git push "https://x-access-token:${GITHUB_APP_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:${GITHUB_REF#refs/heads/})
56-
53+
git diff --quiet && git diff --staged --quiet || (git commit -m "chore(community): update community.json")
54+
55+
- name: Create Pull Request
56+
id: cpr
57+
uses: peter-evans/create-pull-request@v6
58+
with:
59+
token: ${{ steps.get_workflow_token.outputs.token }}
60+
title: 'chore(community): update community.json'
61+
body: 'This PR updates the community.json file with the latest contributors data.'
62+
branch: 'update-contributors'
63+
base: 'main'
64+
author: 'the-json-schema-bot <the-json-schema-bot[bot]@users.noreply.github.com>'
65+
branch-suffix: timestamp
66+
labels: 'sync-contributors'
67+
assignees: 'the-json-schema-bot'
68+
draft: false
69+
signoff: true
70+
add-paths: 'community.json'
71+
72+
# Approving with github bot token because one cannot approve their own PRs
73+
- name: Auto Approve
74+
if: steps.cpr.outputs.pull-request-operation == 'created'
75+
run: gh pr review --approve "${{ steps.cpr.outputs.pull-request-number }}"
76+
env:
77+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5778

79+
- name: Auto Merge PR
80+
if: steps.cpr.outputs.pull-request-operation == 'created'
81+
uses: peter-evans/enable-pull-request-automerge@v3
82+
with:
83+
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
84+
merge-method: 'squash'
85+
token: ${{ steps.get_workflow_token.outputs.token }}
5886

5987

.github/workflows/sync-project-roadmap.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,41 @@ jobs:
9090
9191
# commit updated project data
9292
- name: Commit changes
93-
env:
94-
GITHUB_APP_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
9593
run: |
9694
git config user.name "the-json-schema-bot[bot]"
9795
git config user.email "the-json-schema-bot[bot]@users.noreply.github.com"
9896
git add project_data.json
99-
git diff --quiet && git diff --staged --quiet || (git commit -m "chore(project_data): update project_data.json" && git push "https://x-access-token:${GITHUB_APP_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:${GITHUB_REF#refs/heads/})
97+
git diff --quiet && git diff --staged --quiet || (git commit -m "chore(project_data): update project_data.json")
98+
99+
# create a pull request
100+
- name: Create Pull Request
101+
id: cpr
102+
uses: peter-evans/create-pull-request@v6
103+
with:
104+
token: ${{ steps.get_workflow_token.outputs.token }}
105+
title: 'chore(project_data): update project_data.json'
106+
body: 'This PR updates the project_data.json file with the latest project data.'
107+
branch: 'update-project-data'
108+
base: 'main'
109+
author: 'the-json-schema-bot <the-json-schema-bot[bot]@users.noreply.github.com>'
110+
branch-suffix: timestamp
111+
labels: 'sync-project-data'
112+
assignees: 'the-json-schema-bot'
113+
draft: false
114+
signoff: true
115+
add-paths: 'project_data.json'
100116

117+
# Approving with github bot token because one cannot approve their own PRs
118+
- name: Auto Approve
119+
if: steps.cpr.outputs.pull-request-operation == 'created'
120+
run: gh pr review --approve "${{ steps.cpr.outputs.pull-request-number }}"
121+
env:
122+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
124+
- name: Auto Merge PR
125+
if: steps.cpr.outputs.pull-request-operation == 'created'
126+
uses: peter-evans/enable-pull-request-automerge@v3
127+
with:
128+
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
129+
merge-method: 'squash'
130+
token: ${{ steps.get_workflow_token.outputs.token }}

0 commit comments

Comments
 (0)