Skip to content

Commit cb0b297

Browse files
committed
feat: turn some intputs into secrets
1 parent 42820f8 commit cb0b297

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

.github/workflows/go-check.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@ on:
1919
env:
2020
required: false
2121
type: string
22-
checkout-token:
22+
secrets:
23+
CHECKOUT_TOKEN:
2324
required: false
24-
type: string
25-
default: ${{ github.token }}
26-
checkout-app-id:
25+
CHECKOUT_APP_ID:
2726
required: false
28-
type: string
29-
checkout-private-key:
27+
CHECKOUT_PRIVATE_KEY:
3028
required: false
31-
type: string
3229

3330
jobs:
3431
unit:
@@ -41,19 +38,25 @@ jobs:
4138
ENV: ${{ inputs.env }}
4239
run: |
4340
echo "$ENV" >> $GITHUB_ENV
41+
- name: Inspect checkout secrets
42+
id: checkout-app-secrets
43+
env:
44+
APP_ID: ${{ secrets.CHECKOUT_APP_ID }}
45+
PRIVATE_KEY: ${{ secrets.CHECKOUT_PRIVATE_KEY }}
46+
run: echo "available=$([[ -n \"$APP_ID\" && -n \"$PRIVATE_KEY\" ]] && echo true || echo false)" | tee -a "$GITHUB_OUTPUT"
4447
- name: Create GitHub App installation token
4548
id: checkout-app
46-
if: ${{ inputs.checkout-app-id && inputs.checkout-private-key }}
49+
if: steps.checkout-app-secrets.outputs.available == 'true'
4750
uses: actions/create-github-app-token@v2
4851
with:
49-
app-id: ${{ inputs.checkout-app-id }}
50-
private-key: ${{ inputs.checkout-private-key }}
52+
app-id: ${{ secrets.CHECKOUT_APP_ID }}
53+
private-key: ${{ secrets.CHECKOUT_PRIVATE_KEY }}
5154
owner: ${{ github.repository_owner }}
5255
- name: Check out the repository
5356
uses: actions/checkout@v5
5457
with:
5558
submodules: recursive
56-
token: ${{ steps.checkout-app.outputs.token || inputs.checkout-token }}
59+
token: ${{ steps.checkout-app.outputs.token || secrets.CHECKOUT_TOKEN }}
5760
- name: Extend the GitHub context
5861
id: github
5962
env:

.github/workflows/go-test.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,14 @@ on:
2929
env:
3030
required: false
3131
type: string
32-
checkout-token:
32+
secrets:
33+
CODECOV_TOKEN:
3334
required: false
34-
type: string
35-
default: ${{ github.token }}
36-
checkout-app-id:
35+
CHECKOUT_TOKEN:
3736
required: false
38-
type: string
39-
checkout-private-key:
37+
CHECKOUT_APP_ID:
4038
required: false
41-
type: string
42-
43-
secrets:
44-
CODECOV_TOKEN:
39+
CHECKOUT_PRIVATE_KEY:
4540
required: false
4641

4742
defaults:
@@ -68,13 +63,19 @@ jobs:
6863
ENV: ${{ inputs.env }}
6964
run: |
7065
echo "$ENV" >> $GITHUB_ENV
66+
- name: Inspect checkout secrets
67+
id: checkout-app-secrets
68+
env:
69+
APP_ID: ${{ secrets.CHECKOUT_APP_ID }}
70+
PRIVATE_KEY: ${{ secrets.CHECKOUT_PRIVATE_KEY }}
71+
run: echo "available=$([[ -n \"$APP_ID\" && -n \"$PRIVATE_KEY\" ]] && echo true || echo false)" | tee -a "$GITHUB_OUTPUT"
7172
- name: Create GitHub App installation token
7273
id: checkout-app
73-
if: ${{ inputs.checkout-app-id && inputs.checkout-private-key }}
74+
if: steps.checkout-app-secrets.outputs.available == 'true'
7475
uses: actions/create-github-app-token@v2
7576
with:
76-
app-id: ${{ inputs.checkout-app-id }}
77-
private-key: ${{ inputs.checkout-private-key }}
77+
app-id: ${{ secrets.CHECKOUT_APP_ID }}
78+
private-key: ${{ secrets.CHECKOUT_PRIVATE_KEY }}
7879
owner: ${{ github.repository_owner }}
7980
- name: Use msys2 on windows
8081
if: matrix.os == 'windows'
@@ -87,7 +88,7 @@ jobs:
8788
uses: actions/checkout@v5
8889
with:
8990
submodules: recursive
90-
token: ${{ steps.checkout-app.outputs.token || inputs.checkout-token }}
91+
token: ${{ steps.checkout-app.outputs.token || secrets.CHECKOUT_TOKEN }}
9192
- name: Check out the latest stable version of Go
9293
id: stable
9394
uses: actions/setup-go@v5

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## Unreleased
88
### Added
99
- `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
10+
- `CHECKOUT_TOKEN`, `CHECKOUT_APP_ID` and `CHECKOUT_PRIVATE_KEY` secrets 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)