Skip to content

Commit b62fcdc

Browse files
drmowinckelsclaude
andauthored
Switch from PATs to Jinx GitHub App for authentication (#590)
Replace GLOBAL_GHA_PAT, ADMIN_TOKEN, and push-to-protected SSH key with actions/create-github-app-token across build-preview, hello, merge-pending, and global-team workflows. Convert global-team.yml from push-protected to peter-evans/create-pull-request to avoid needing admin permissions. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 21e092a commit b62fcdc

4 files changed

Lines changed: 49 additions & 29 deletions

File tree

.github/workflows/build-preview.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,22 @@ jobs:
3636
with:
3737
fetch-depth: 2
3838

39+
- name: Generate app token
40+
id: app-token
41+
uses: actions/create-github-app-token@v1
42+
with:
43+
app-id: ${{ secrets.JINX_APP_ID }}
44+
private-key: ${{ secrets.JINX_PRIVATE_KEY }}
45+
owner: rladies
46+
3947
- name: Set env parameters
4048
run: |
4149
ver=$(cat .hugoversion)
4250
echo "hugovr=$ver" >> $GITHUB_ENV
4351
echo "repo_owner=$(dirname ${{ env.repo_name }})" >> $GITHUB_ENV
4452
echo "repo_name=$(basename ${{ env.repo_name }})" >> $GITHUB_ENV
4553
echo "netalias=d${{ env.directory }}-r${{ env.rid}}" >> $GITHUB_ENV
46-
echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
47-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
48-
echo "token=${{ secrets.GLOBAL_GHA_PAT }}" >> $GITHUB_ENV
49-
fi
54+
echo "token=${{ steps.app-token.outputs.token }}" >> $GITHUB_ENV
5055
5156
- name: Install cURL Headers
5257
run: |
@@ -70,7 +75,7 @@ jobs:
7075
if: ${{ (env.on_fork != 'true') && env.directory != 'main' }}
7176
with:
7277
name: entries
73-
github_token: ${{ secrets.GLOBAL_GHA_PAT }}
78+
github_token: ${{ steps.app-token.outputs.token }}
7479
run_id: ${{ env.directory }}
7580
repo: rladies/directory
7681
path: entries/

.github/workflows/global-team.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ jobs:
1818
name: Retrieve Airtable data
1919
runs-on: ubuntu-latest
2020
steps:
21+
- name: Generate app token
22+
id: app-token
23+
uses: actions/create-github-app-token@v1
24+
with:
25+
app-id: ${{ secrets.JINX_APP_ID }}
26+
private-key: ${{ secrets.JINX_PRIVATE_KEY }}
27+
owner: rladies
28+
2129
- name: Checkout repository
2230
uses: actions/checkout@v6
2331
with:
24-
ssh-key: ${{ secrets.push-to-protected }}
32+
token: ${{ steps.app-token.outputs.token }}
2533

2634
- name: Install cURL Headers
2735
run: |
@@ -41,22 +49,15 @@ jobs:
4149
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }}
4250
run: Rscript scripts/get_global_team.R
4351

44-
- name: Configure Git
45-
run: |
46-
git config --global user.name "github-actions[bot]"
47-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
48-
49-
- name: Commit Changes
50-
env:
51-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52-
run: |
53-
git add content/about-us/global-team/img
54-
git add data/global_team
55-
git commit -m "Automated update: Update Global Team" || echo "No new data to commit"
56-
57-
- name: Pushing to the protected branch 'main'
58-
uses: CasperWA/push-protected@v2
52+
- name: Create Pull Request
53+
uses: peter-evans/create-pull-request@v7
5954
with:
60-
token: ${{ secrets.ADMIN_TOKEN }}
61-
branch: main
62-
unprotect_reviews: true
55+
token: ${{ steps.app-token.outputs.token }}
56+
add-paths: |
57+
content/about-us/global-team/img
58+
data/global_team
59+
commit-message: "Automated update: Update Global Team"
60+
branch: automated/global-team-update
61+
title: "Automated update: Update Global Team"
62+
body: "Weekly automated update of Global Team data from Airtable."
63+
labels: automated

.github/workflows/hello.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ jobs:
1010
if: github.event.action == 'opened'
1111
runs-on: ubuntu-latest
1212
steps:
13+
- name: Generate app token
14+
id: app-token
15+
uses: actions/create-github-app-token@v1
16+
with:
17+
app-id: ${{ secrets.JINX_APP_ID }}
18+
private-key: ${{ secrets.JINX_PRIVATE_KEY }}
19+
owner: rladies
20+
1321
- name: Get author
1422
id: author
1523
run: |
@@ -23,6 +31,7 @@ jobs:
2331
id: check
2432
env:
2533
AUTHOR: ${{ steps.author.outputs.login }}
34+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
2635
run: |
2736
if [[ "$AUTHOR" == *"[bot]" ]]; then
2837
echo "say_hello=false" >> $GITHUB_OUTPUT
@@ -31,7 +40,7 @@ jobs:
3140
3241
status=$(curl -sg \
3342
-o /dev/null -w "%{http_code}" \
34-
-H "Authorization: Bearer ${{ secrets.GLOBAL_GHA_PAT }}" \
43+
-H "Authorization: Bearer $GITHUB_TOKEN" \
3544
-H "X-GitHub-Api-Version: 2022-11-28" \
3645
"https://api.github.com/orgs/rladies/teams/global/memberships/$AUTHOR")
3746

.github/workflows/merge-pending.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,21 @@ jobs:
1919
- name: Checkout Repository
2020
uses: actions/checkout@v6
2121

22-
- name: Setup GitHub CLI
23-
run: |
24-
echo "${{ secrets.ADMIN_TOKEN }}" | gh auth login --with-token
25-
gh config set prompt-enabled false
22+
- name: Generate app token
23+
id: app-token
24+
uses: actions/create-github-app-token@v1
25+
with:
26+
app-id: ${{ secrets.JINX_APP_ID }}
27+
private-key: ${{ secrets.JINX_PRIVATE_KEY }}
28+
owner: rladies
2629

2730
- name: Get current date for comparison
2831
id: get_date
2932
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
3033

3134
- name: Find and Process PRs with "pending" label
35+
env:
36+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
3237
run: |
3338
PR_NUMBERS=$(gh pr list --label "pending" --state "open" --json number,title,isDraft -q '.[] | select(.isDraft == false) | .number')
3439

0 commit comments

Comments
 (0)