Skip to content

Commit 67c4f34

Browse files
authored
ci: 👷 use GitHub App tokens for workflows (#17)
# Description Aligning with the other template repos, this makes use of the GitHub App token for better security practices.
1 parent 8dc59ba commit 67c4f34

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

.github/workflows/add-to-project.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
uses: seedcase-project/.github/.github/workflows/reusable-add-to-project.yml@main
2020
with:
2121
board-number: 18
22+
app-id: ${{ vars.ADD_TO_BOARD_APP_ID }}
2223
secrets:
2324
add-to-board-token: ${{ secrets.ADD_TO_BOARD }}
2425
gh-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/sync-files.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,33 @@ jobs:
99
sync:
1010
runs-on: ubuntu-latest
1111
steps:
12+
- uses: actions/create-github-app-token@v2
13+
id: app-token
14+
with:
15+
owner: ${{ github.repository_owner }}
16+
app-id: ${{ vars.SYNC_FILES_APP_ID }}
17+
private-key: ${{ secrets.SYNC_FILES_TOKEN }}
18+
1219
- name: Checkout Repository
13-
uses: actions/checkout@main
20+
uses: actions/checkout@v4
21+
with:
22+
token: ${{ steps.app-token.outputs.token }}
23+
24+
# Taken from https://github.com/actions/create-github-app-token/
25+
- name: Get GitHub App User ID
26+
id: get-user-id
27+
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
28+
env:
29+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
1430

1531
- name: Run GitHub File Sync
1632
uses: BetaHuhn/repo-file-sync-action@v1
1733
with:
18-
GH_PAT: ${{ secrets.SYNC_PAT }}
34+
GH_INSTALLATION_TOKEN: ${{ steps.app-token.outputs.token }}
1935
ASSIGNEES: lwjohnst86
2036
IS_FINE_GRAINED: true
21-
GIT_USERNAME: lwjohnst86
22-
GIT_EMAIL: lwjohnst@gmail.com
37+
GIT_USERNAME: ${{ steps.app-token.outputs.app-slug }}[bot]
38+
GIT_EMAIL: ${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com
2339
COMMIT_PREFIX: "chore(sync): :hammer: "
24-
BRANCH_PREFIX: chore
25-
TEAM_REVIEWERS: admin
40+
COMMIT_EACH_FILE: false
41+
BRANCH_PREFIX: chore/data-package-sync

0 commit comments

Comments
 (0)