Skip to content

Commit 9a4b5de

Browse files
ethanbienstockEthan Bienstockclaude
authored
ci: use GeoSetBot app token in workflows and fix fork PR secrets (#341)
Replace GITHUB_TOKEN with GeoSetBot GitHub App installation tokens in version-bump and sync-wiki workflows to bypass branch protections. Switch docker-build from pull_request to pull_request_target so fork PRs have access to secrets for Docker Hub push. Closes #338 Co-authored-by: Ethan Bienstock <ethan.bienstock@acf.hhs.gov> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c3a7685 commit 9a4b5de

3 files changed

Lines changed: 41 additions & 17 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Docker Build
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
branches:
66
- main
77
types: [opened, synchronize, reopened]
@@ -34,6 +34,8 @@ jobs:
3434
steps:
3535
- name: Checkout Code
3636
uses: actions/checkout@v4
37+
with:
38+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
3739

3840
- name: Set up Docker Buildx
3941
uses: docker/setup-buildx-action@v3
@@ -66,6 +68,8 @@ jobs:
6668
steps:
6769
- name: Checkout Code
6870
uses: actions/checkout@v4
71+
with:
72+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
6973

7074
- name: Set up Docker Buildx
7175
uses: docker/setup-buildx-action@v3
@@ -100,6 +104,7 @@ jobs:
100104
- name: Checkout Code
101105
uses: actions/checkout@v4
102106
with:
107+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
103108
fetch-depth: 0
104109

105110
- name: Check for sample-data changes
@@ -124,6 +129,8 @@ jobs:
124129
steps:
125130
- name: Checkout Code
126131
uses: actions/checkout@v4
132+
with:
133+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
127134

128135
- name: Set up Docker Buildx
129136
uses: docker/setup-buildx-action@v3

.github/workflows/sync-wiki.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ on:
1010
jobs:
1111
sync-wiki:
1212
runs-on: ubuntu-latest
13-
permissions:
14-
contents: write
1513

1614
steps:
15+
- name: Generate GeoSetBot token
16+
id: app-token
17+
uses: actions/create-github-app-token@v1
18+
with:
19+
app-id: ${{ secrets.APP_ID }}
20+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
21+
1722
- name: Checkout main repo
1823
uses: actions/checkout@v4
1924

@@ -22,7 +27,7 @@ jobs:
2227
with:
2328
repository: ${{ github.repository }}.wiki
2429
path: wiki-repo
25-
token: ${{ secrets.GITHUB_TOKEN }}
30+
token: ${{ steps.app-token.outputs.token }}
2631

2732
- name: Sync wiki files
2833
run: |
@@ -31,8 +36,8 @@ jobs:
3136
- name: Push changes to wiki
3237
run: |
3338
cd wiki-repo
34-
git config user.name "github-actions[bot]"
35-
git config user.email "github-actions[bot]@users.noreply.github.com"
39+
git config user.name "geoset-bot[bot]"
40+
git config user.email "geoset-bot[bot]@users.noreply.github.com"
3641
git add -A
3742
if git diff --cached --quiet; then
3843
echo "No wiki changes to sync."

.github/workflows/version-bump.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ on:
55
branches:
66
- main
77

8-
permissions:
9-
contents: write
10-
pull-requests: write
11-
128
concurrency:
139
group: version-bump
1410
cancel-in-progress: false
@@ -20,15 +16,22 @@ jobs:
2016
if: "!startsWith(github.event.head_commit.message, 'chore: bump version to')"
2117

2218
steps:
19+
- name: Generate GeoSetBot token
20+
id: app-token
21+
uses: actions/create-github-app-token@v1
22+
with:
23+
app-id: ${{ secrets.APP_ID }}
24+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
25+
2326
- name: Checkout Code
2427
uses: actions/checkout@v4
2528
with:
26-
token: ${{ secrets.GITHUB_TOKEN }}
29+
token: ${{ steps.app-token.outputs.token }}
2730

2831
- name: Get PR info
2932
id: pr
3033
env:
31-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
3235
run: |
3336
PR_JSON=$(gh pr list --search "${{ github.sha }}" --state merged --json title,number --jq '.[0]')
3437
PR_TITLE=$(echo "$PR_JSON" | jq -r '.title // empty')
@@ -51,10 +54,10 @@ jobs:
5154
5255
- name: Create or update Pull Request
5356
env:
54-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
5558
run: |
56-
git config user.name "github-actions[bot]"
57-
git config user.email "github-actions[bot]@users.noreply.github.com"
59+
git config user.name "geoset-bot[bot]"
60+
git config user.email "geoset-bot[bot]@users.noreply.github.com"
5861
5962
# Check for an existing open version bump PR
6063
EXISTING_PR=$(gh pr list --search "chore: bump version to" --state open \
@@ -104,8 +107,17 @@ jobs:
104107
new_version: ${{ steps.version.outputs.new_version }}
105108

106109
steps:
110+
- name: Generate GeoSetBot token
111+
id: app-token
112+
uses: actions/create-github-app-token@v1
113+
with:
114+
app-id: ${{ secrets.APP_ID }}
115+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
116+
107117
- name: Checkout Code
108118
uses: actions/checkout@v4
119+
with:
120+
token: ${{ steps.app-token.outputs.token }}
109121

110122
- name: Extract version
111123
id: version
@@ -115,8 +127,8 @@ jobs:
115127
116128
- name: Create tag
117129
run: |
118-
git config user.name "github-actions[bot]"
119-
git config user.email "github-actions[bot]@users.noreply.github.com"
130+
git config user.name "geoset-bot[bot]"
131+
git config user.email "geoset-bot[bot]@users.noreply.github.com"
120132
git tag "v${{ steps.version.outputs.new_version }}"
121133
git push origin "v${{ steps.version.outputs.new_version }}"
122134

0 commit comments

Comments
 (0)