Skip to content

Commit 1d8eaa4

Browse files
committed
Use the {upstream,pr,test}-repo information from the repository config
We just started to pass the project-specific configuration stored in the `CONFIG` repository variable to the GitHub Actions of GitGitGadget. That configuration contains information about the correct repositories to target (which might not be `gitgitgadget/git` and friends). Let's use this information when obtaining (and using) the installation access tokens. This is especially necessary when creating and updating that Check Run in `handle-pr-push` and in `handle-pr-comment`. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 146bf8d commit 1d8eaa4

File tree

5 files changed

+46
-38
lines changed

5 files changed

+46
-38
lines changed

.github/workflows/handle-new-mails.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,24 @@ jobs:
1818
with:
1919
app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
2020
private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
21-
owner: gitgitgadget
22-
repositories: git
21+
owner: ${{ fromJSON(vars.CONFIG).repo.owner }}
22+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
2323
- uses: actions/create-github-app-token@v1
24+
if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.baseOwner) }}
2425
id: upstream-repo-token
2526
with:
2627
app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }}
2728
private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }}
28-
owner: git
29-
repositories: git
29+
owner: ${{ fromJSON(vars.CONFIG).repo.baseOwner }}
30+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
3031
- uses: actions/create-github-app-token@v1
32+
if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.testOwner) }}
3133
id: test-repo-token
3234
with:
3335
app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }}
3436
private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }}
35-
owner: dscho
36-
repositories: git
37+
owner: ${{ fromJSON(vars.CONFIG).repo.testOwner }}
38+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
3739
- uses: gitgitgadget/gitgitgadget/handle-new-mails@v1
3840
with:
3941
config: ${{ vars.CONFIG }}

.github/workflows/handle-pr-comment.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,24 @@ jobs:
2727
with:
2828
app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
2929
private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
30-
owner: gitgitgadget
31-
repositories: git
30+
owner: ${{ fromJSON(vars.CONFIG).repo.owner }}
31+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
3232
- uses: actions/create-github-app-token@v1
33+
if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.baseOwner) }}
3334
id: upstream-repo-token
3435
with:
3536
app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }}
3637
private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }}
37-
owner: git
38-
repositories: git
38+
owner: ${{ fromJSON(vars.CONFIG).repo.baseOwner }}
39+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
3940
- uses: actions/create-github-app-token@v1
41+
if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.testOwner) }}
4042
id: test-repo-token
4143
with:
4244
app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }}
4345
private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }}
44-
owner: dscho
45-
repositories: git
46+
owner: ${{ fromJSON(vars.CONFIG).repo.testOwner }}
47+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
4648
- name: create a check run
4749
id: create-check-run
4850
run: |
@@ -67,9 +69,9 @@ jobs:
6769
echo "repo=$repo" >> $GITHUB_OUTPUT
6870
6971
export GH_TOKEN="$(case "$repo" in
70-
gitgitgadget/git) echo "${{ steps.pr-repo-token.outputs.token }}";;
71-
git/git) echo "${{ steps.upstream-repo-token.outputs.token }}";;
72-
dscho/git) echo "${{ steps.test-repo-token.outputs.token }}";;
72+
'${{ fromJSON(vars.CONFIG).repo.owner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.pr-repo-token.outputs.token }}";;
73+
'${{ fromJSON(vars.CONFIG).repo.baseOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.upstream-repo-token.outputs.token }}";;
74+
'${{ fromJSON(vars.CONFIG).repo.testOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.test-repo-token.outputs.token }}";;
7375
*) echo "${{ secrets.GITHUB_TOKEN }}";;
7476
esac
7577
)"
@@ -97,9 +99,9 @@ jobs:
9799
if: always() && steps.create-check-run.outputs.check_run_id != ''
98100
run: |
99101
export GH_TOKEN="$(case "${{ steps.create-check-run.outputs.repo }}" in
100-
gitgitgadget/git) echo "${{ steps.pr-repo-token.outputs.token }}";;
101-
git/git) echo "${{ steps.upstream-repo-token.outputs.token }}";;
102-
dscho/git) echo "${{ steps.test-repo-token.outputs.token }}";;
102+
'${{ fromJSON(vars.CONFIG).repo.owner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.pr-repo-token.outputs.token }}";;
103+
'${{ fromJSON(vars.CONFIG).repo.baseOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.upstream-repo-token.outputs.token }}";;
104+
'${{ fromJSON(vars.CONFIG).repo.testOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.test-repo-token.outputs.token }}";;
103105
*) echo "${{ secrets.GITHUB_TOKEN }}";;
104106
esac
105107
)"

.github/workflows/handle-pr-push.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,24 @@ jobs:
2727
with:
2828
app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
2929
private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
30-
owner: gitgitgadget
31-
repositories: git
30+
owner: ${{ fromJSON(vars.CONFIG).repo.owner }}
31+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
3232
- uses: actions/create-github-app-token@v1
33+
if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.baseOwner) }}
3334
id: upstream-repo-token
3435
with:
3536
app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }}
3637
private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }}
37-
owner: git
38-
repositories: git
38+
owner: ${{ fromJSON(vars.CONFIG).repo.baseOwner }}
39+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
3940
- uses: actions/create-github-app-token@v1
41+
if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.testOwner) }}
4042
id: test-repo-token
4143
with:
4244
app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }}
4345
private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }}
44-
owner: dscho
45-
repositories: git
46+
owner: ${{ fromJSON(vars.CONFIG).repo.testOwner }}
47+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
4648
- name: create a check run
4749
id: create-check-run
4850
run: |
@@ -65,9 +67,9 @@ jobs:
6567
echo "repo=$repo" >> $GITHUB_OUTPUT
6668
6769
export GH_TOKEN="$(case "$repo" in
68-
gitgitgadget/git) echo "${{ steps.pr-repo-token.outputs.token }}";;
69-
git/git) echo "${{ steps.upstream-repo-token.outputs.token }}";;
70-
dscho/git) echo "${{ steps.test-repo-token.outputs.token }}";;
70+
'${{ fromJSON(vars.CONFIG).repo.owner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.pr-repo-token.outputs.token }}";;
71+
'${{ fromJSON(vars.CONFIG).repo.baseOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.upstream-repo-token.outputs.token }}";;
72+
'${{ fromJSON(vars.CONFIG).repo.testOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.test-repo-token.outputs.token }}";;
7173
*) echo "${{ secrets.GITHUB_TOKEN }}";;
7274
esac
7375
)"
@@ -92,9 +94,9 @@ jobs:
9294
if: always() && steps.create-check-run.outputs.check_run_id != ''
9395
run: |
9496
export GH_TOKEN="$(case "${{ steps.create-check-run.outputs.repo }}" in
95-
gitgitgadget/git) echo "${{ steps.pr-repo-token.outputs.token }}";;
96-
git/git) echo "${{ steps.upstream-repo-token.outputs.token }}";;
97-
dscho/git) echo "${{ steps.test-repo-token.outputs.token }}";;
97+
'${{ fromJSON(vars.CONFIG).repo.owner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.pr-repo-token.outputs.token }}";;
98+
'${{ fromJSON(vars.CONFIG).repo.baseOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.upstream-repo-token.outputs.token }}";;
99+
'${{ fromJSON(vars.CONFIG).repo.testOwner }}/${{ fromJSON(vars.CONFIG).repo.name }}') echo "${{ steps.test-repo-token.outputs.token }}";;
98100
*) echo "${{ secrets.GITHUB_TOKEN }}";;
99101
esac
100102
)"

.github/workflows/update-mail-to-commit-notes.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
with:
2020
app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
2121
private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
22-
owner: gitgitgadget
23-
repositories: git
22+
owner: ${{ fromJSON(vars.CONFIG).repo.owner }}
23+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
2424
- uses: gitgitgadget/gitgitgadget/update-mail-to-commit-notes@v1
2525
with:
2626
config: ${{ vars.CONFIG }}

.github/workflows/update-prs.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,24 @@ jobs:
1818
with:
1919
app-id: ${{ secrets.GITGITGADGET_GITHUB_APP_ID }}
2020
private-key: ${{ secrets.GITGITGADGET_GITHUB_APP_PRIVATE_KEY }}
21-
owner: gitgitgadget
22-
repositories: git
21+
owner: ${{ fromJSON(vars.CONFIG).repo.owner }}
22+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
2323
- uses: actions/create-github-app-token@v1
24+
if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.baseOwner) }}
2425
id: upstream-repo-token
2526
with:
2627
app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }}
2728
private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }}
28-
owner: git
29-
repositories: git
29+
owner: ${{ fromJSON(vars.CONFIG).repo.baseOwner }}
30+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
3031
- uses: actions/create-github-app-token@v1
32+
if: ${{ contains(fromJSON(vars.CONFIG).repo.owners, fromJSON(vars.CONFIG).repo.testOwner) }}
3133
id: test-repo-token
3234
with:
3335
app-id: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_ID }}
3436
private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }}
35-
owner: dscho
36-
repositories: git
37+
owner: ${{ fromJSON(vars.CONFIG).repo.testOwner }}
38+
repositories: ${{ fromJSON(vars.CONFIG).repo.name }}
3739
- uses: gitgitgadget/gitgitgadget/update-prs@v1
3840
with:
3941
config: ${{ vars.CONFIG }}

0 commit comments

Comments
 (0)