Skip to content

Commit 42820f8

Browse files
committed
feat: support app creds for checkout
1 parent 5de460f commit 42820f8

File tree

5 files changed

+42
-31
lines changed

5 files changed

+42
-31
lines changed

.github/workflows/go-check.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@ on:
1212
required: false
1313
type: boolean
1414
default: false
15-
env:
16-
required: false
17-
type: string
1815
runner:
1916
required: false
2017
type: string
2118
default: '"ubuntu-latest"'
19+
env:
20+
required: false
21+
type: string
2222
checkout-token:
2323
required: false
2424
type: string
2525
default: ${{ github.token }}
26+
checkout-app-id:
27+
required: false
28+
type: string
29+
checkout-private-key:
30+
required: false
31+
type: string
2632

2733
jobs:
2834
unit:
@@ -35,11 +41,19 @@ jobs:
3541
ENV: ${{ inputs.env }}
3642
run: |
3743
echo "$ENV" >> $GITHUB_ENV
44+
- name: Create GitHub App installation token
45+
id: checkout-app
46+
if: ${{ inputs.checkout-app-id && inputs.checkout-private-key }}
47+
uses: actions/create-github-app-token@v2
48+
with:
49+
app-id: ${{ inputs.checkout-app-id }}
50+
private-key: ${{ inputs.checkout-private-key }}
51+
owner: ${{ github.repository_owner }}
3852
- name: Check out the repository
3953
uses: actions/checkout@v5
4054
with:
4155
submodules: recursive
42-
token: ${{ inputs.checkout-token }}
56+
token: ${{ steps.checkout-app.outputs.token || inputs.checkout-token }}
4357
- name: Extend the GitHub context
4458
id: github
4559
env:

.github/workflows/go-test.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Go Test
22
on:
33
workflow_call:
44
inputs:
5+
os-versions:
6+
required: false
7+
type: string
8+
default: '["ubuntu", "windows", "macos"]'
59
go-versions:
610
required: false
711
type: string
@@ -10,9 +14,6 @@ on:
1014
required: false
1115
type: boolean
1216
default: false
13-
env:
14-
required: false
15-
type: string
1617
runner-ubuntu:
1718
required: false
1819
type: string
@@ -25,14 +26,20 @@ on:
2526
required: false
2627
type: string
2728
default: '"macos-latest"'
28-
os-versions:
29+
env:
2930
required: false
3031
type: string
31-
default: '["ubuntu", "windows", "macos"]'
3232
checkout-token:
3333
required: false
3434
type: string
3535
default: ${{ github.token }}
36+
checkout-app-id:
37+
required: false
38+
type: string
39+
checkout-private-key:
40+
required: false
41+
type: string
42+
3643
secrets:
3744
CODECOV_TOKEN:
3845
required: false
@@ -61,6 +68,14 @@ jobs:
6168
ENV: ${{ inputs.env }}
6269
run: |
6370
echo "$ENV" >> $GITHUB_ENV
71+
- name: Create GitHub App installation token
72+
id: checkout-app
73+
if: ${{ inputs.checkout-app-id && inputs.checkout-private-key }}
74+
uses: actions/create-github-app-token@v2
75+
with:
76+
app-id: ${{ inputs.checkout-app-id }}
77+
private-key: ${{ inputs.checkout-private-key }}
78+
owner: ${{ github.repository_owner }}
6479
- name: Use msys2 on windows
6580
if: matrix.os == 'windows'
6681
# The executable for msys2 is also called bash.cmd
@@ -72,7 +87,7 @@ jobs:
7287
uses: actions/checkout@v5
7388
with:
7489
submodules: recursive
75-
token: ${{ inputs.checkout-token }}
90+
token: ${{ steps.checkout-app.outputs.token || inputs.checkout-token }}
7691
- name: Check out the latest stable version of Go
7792
id: stable
7893
uses: actions/setup-go@v5

.github/workflows/release-check.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,10 @@ on:
1414
required: false
1515
type: string
1616
default: '/'
17-
env:
18-
required: false
19-
type: string
2017
runner:
2118
required: false
2219
type: string
2320
default: '"ubuntu-latest"'
24-
checkout-token:
25-
required: false
26-
type: string
27-
default: ${{ github.token }}
2821
outputs:
2922
json:
3023
description: JSON aggregation of release.json artifacts

.github/workflows/releaser.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,10 @@ on:
1818
required: false
1919
type: boolean
2020
default: false
21-
env:
22-
required: false
23-
type: string
2421
runner:
2522
required: false
2623
type: string
2724
default: '"ubuntu-latest"'
28-
checkout-token:
29-
required: false
30-
type: string
31-
default: ${{ github.token }}
32-
release-token:
33-
required: false
34-
type: string
35-
default: ${{ github.token }}
3625
outputs:
3726
json:
3827
description: JSON aggregation of release.json artifacts
@@ -171,7 +160,7 @@ jobs:
171160
generate_release_notes: true
172161
target_commitish: ${{ github.sha }}
173162
make_latest: ${{ steps.version.outputs.prefix == 'v' && steps.version.outputs.suffix == '' && steps.version.outputs.tag == steps.latest.outputs.latest }}
174-
token: ${{ secrets.UCI_GITHUB_TOKEN || inputs.release-token }}
163+
token: ${{ secrets.UCI_GITHUB_TOKEN || github.token }}
175164
- name: Create release.json
176165
if: steps.release.outputs.id != ''
177166
id: json

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88
### Added
9-
- `env` input support to `go-test`, `go-check`, `releaser` and `release-check` workflows
10-
- `checkout-token` input support to `go-test`, `go-check`, `releaser` and `release-check` workflows
9+
- `env` input support to `go-test` and `go-check` workflows
10+
- `checkout-token`, `checkout-app-id` and `checkout-private-key` input support to `go-test` and `go-check` workflows
1111
- custom `runner` configuration to most workflows
1212
- `os-versions` input support to `go-test` workflow
1313

0 commit comments

Comments
 (0)