Skip to content

Commit b391128

Browse files
committed
Use the official GitHub Action to obtain installation access tokens
When I committed the first workflow in e84a016 (Add a workflow to synchronize refs from git/git to gitgitgadget/git, 2023-08-18), I had missed the first public release of `actions/create-github-app-token` by _mere days_: The first version of that GitHub Action to be officially published to the GitHub Marketplace was v1.1.0, on August 22nd, 2023: https://github.com/actions/create-github-app-token/releases/tag/v1.1.0, i.e. a mere 4 days after I had committed the initial version of the `sync-ref` workflow. That was the reason why, when I scoured around for a GitHub Action that could be used to obtain an installation access token, I only found a third-party one. I don't exactly remember how I got aware of the official Action provided by GitHub itself, but I know that I immediately opened #5 so that I wouldn't forget to eventually migrate to that Action. This commit is it. With this, we switch from that 3rd-party Action to the official GitHub one. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 53fc07d commit b391128

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

.github/workflows/sync-git-gui.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
id: check
2626
with:
2727
script: |
28+
const [targetRepoOwner, targetRepoName] = process.env.TARGET_REPOSITORY.split('/')
29+
core.setOutput('target-repo-owner', targetRepoOwner)
30+
core.setOutput('target-repo-name', targetRepoName)
31+
2832
const sleep = async (milliseconds) => {
2933
return new Promise(resolve => setTimeout(resolve, milliseconds))
3034
}
@@ -109,12 +113,13 @@ jobs:
109113
core.setOutput('to-fetch', [...toFetch].join(' '))
110114
- name: obtain installation token
111115
if: steps.check.outputs.refspec != ''
112-
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
116+
uses: actions/create-github-app-token@v1
113117
id: token
114118
with:
115-
app_id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
116-
private_key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
117-
repository: ${{ env.TARGET_REPOSITORY }}
119+
app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
120+
private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
121+
owner: ${{ steps.check.outputs.target-repo-owner }}
122+
repositories: ${{ steps.check.outputs.target-repo-name }}
118123
- name: set authorization header
119124
if: steps.check.outputs.refspec != ''
120125
uses: actions/github-script@v7

.github/workflows/sync-gitster-git.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
id: check
2525
with:
2626
script: |
27+
const [targetRepoOwner, targetRepoName] = process.env.TARGET_REPOSITORY.split('/')
28+
core.setOutput('target-repo-owner', targetRepoOwner)
29+
core.setOutput('target-repo-name', targetRepoName)
30+
2731
const sleep = async (milliseconds) => {
2832
return new Promise(resolve => setTimeout(resolve, milliseconds))
2933
}
@@ -95,12 +99,13 @@ jobs:
9599
core.setOutput('to-fetch', [...toFetch].join(' '))
96100
- name: obtain installation token
97101
if: steps.check.outputs.refspec != ''
98-
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
102+
uses: actions/create-github-app-token@v1
99103
id: token
100104
with:
101-
app_id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
102-
private_key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
103-
repository: ${{ env.TARGET_REPOSITORY }}
105+
app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
106+
private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
107+
owner: ${{ steps.check.outputs.target-repo-owner }}
108+
repositories: ${{ steps.check.outputs.target-repo-name }}
104109
- name: set authorization header
105110
if: steps.check.outputs.refspec != ''
106111
uses: actions/github-script@v7

.github/workflows/sync-ref.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
id: check
3131
with:
3232
script: |
33+
const [targetRepoOwner, targetRepoName] = process.env.TARGET_REPOSITORY.split('/')
34+
core.setOutput('target-repo-owner', targetRepoOwner)
35+
core.setOutput('target-repo-name', targetRepoName)
36+
3337
const getSHA = async (repository, ref) => {
3438
if (ref.startsWith('refs/heads/') || ref.startsWith('refs/tags/')) ref = ref.substring(4)
3539
else throw new Error(`Cannot handle ref '${ref}`)
@@ -60,12 +64,13 @@ jobs:
6064
core.setOutput('target-sha', targetSHA || '')
6165
- name: obtain installation token
6266
if: steps.check.outputs.skip == 'false'
63-
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
67+
uses: actions/create-github-app-token@v1
6468
id: token
6569
with:
66-
app_id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
67-
private_key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
68-
repository: ${{ env.TARGET_REPOSITORY }}
70+
app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
71+
private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
72+
owner: ${{ steps.check.outputs.target-repo-owner }}
73+
repositories: ${{ steps.check.outputs.target-repo-name }}
6974
- name: set authorization header
7075
if: steps.check.outputs.skip == 'false'
7176
uses: actions/github-script@v7

0 commit comments

Comments
 (0)