Skip to content

Commit e324a87

Browse files
committed
chore: improve workflows security
1 parent 83d7d5b commit e324a87

4 files changed

Lines changed: 31 additions & 8 deletions

File tree

.github/workflows/checks.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@ on:
55
branches:
66
- main
77
pull_request:
8-
permissions:
9-
checks: write # Allow write access to checks to allow annotation of code in the PR.
10-
contents: read
11-
pull-requests: read
8+
9+
permissions: {}
10+
1211
env:
1312
CGO_ENABLED: 0
1413
GOLANGCI_LINT_VERSION: v2.12
14+
1515
jobs:
1616
go-lint-checks:
1717
runs-on: ubuntu-latest
18+
permissions:
19+
checks: write # Allow write access to checks to allow annotation of code in the PR.
20+
contents: read
21+
pull-requests: read
1822
steps:
1923
- uses: actions/checkout@v6
24+
with:
25+
persist-credentials: false
2026
- uses: actions/setup-go@v6
2127
with:
2228
go-version-file: go.mod
@@ -28,6 +34,8 @@ jobs:
2834
runs-on: ubuntu-latest
2935
steps:
3036
- uses: actions/checkout@v6
37+
with:
38+
persist-credentials: false
3139
- uses: actions/setup-go@v6
3240
with:
3341
go-version-file: go.mod

.github/workflows/go-cross.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
branches:
55
- main
66
pull_request:
7-
permissions:
8-
contents: read
9-
pull-requests: read
7+
8+
permissions: {}
9+
1010
jobs:
1111
cross:
1212
name: Build on ${{ matrix.os }} with Go ${{ matrix.go-version }}
@@ -26,6 +26,8 @@ jobs:
2626
steps:
2727
- name: Checkout code
2828
uses: actions/checkout@v6
29+
with:
30+
persist-credentials: false
2931
- name: Set up Go
3032
uses: actions/setup-go@v6
3133
with:

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ jobs:
3333
- windows
3434
steps:
3535
- uses: actions/checkout@v6
36+
with:
37+
persist-credentials: false
3638
- uses: actions/setup-go@v6
3739
with:
3840
check-latest: true
3941
go-version-file: go.mod
42+
cache: false
4043
- name: Build ${{ matrix.app }} for ${{ matrix.go-os }}/${{ matrix.go-arch }}
4144
run: |
4245
go build \
@@ -65,6 +68,8 @@ jobs:
6568
expose_ports: "5001 5002 5003 8053 8055 8443"
6669
steps:
6770
- uses: actions/checkout@v6
71+
with:
72+
persist-credentials: false
6873
- name: Download ${{ matrix.app }} artifacts
6974
uses: actions/download-artifact@v8
7075
with:
@@ -147,6 +152,6 @@ jobs:
147152
for artifact in *; do
148153
tar czf ${artifact}.tar.gz ${artifact}
149154
zip -r ${artifact}.zip ${artifact}
150-
gh release upload ${{ github.ref_name }} ${artifact}.* \
155+
gh release upload ${GITHUB_REF_NAME} ${artifact}.* \
151156
--repo ${{ github.repository }};
152157
done

.github/workflows/tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
# https://github.com/marketplace/actions/checkout
2020
- name: Check out code
2121
uses: actions/checkout@v6
22+
with:
23+
persist-credentials: false
2224
# https://github.com/marketplace/actions/setup-go-environment
2325
- name: Set up Go
2426
uses: actions/setup-go@v6
@@ -43,6 +45,8 @@ jobs:
4345
steps:
4446
- name: Check out code
4547
uses: actions/checkout@v6
48+
with:
49+
persist-credentials: false
4650
- name: Set up Go
4751
uses: actions/setup-go@v6
4852
with:
@@ -64,6 +68,8 @@ jobs:
6468
runs-on: ubuntu-latest
6569
steps:
6670
- uses: actions/checkout@v6
71+
with:
72+
persist-credentials: false
6773
- uses: actions/setup-go@v6
6874
with:
6975
go-version: stable
@@ -91,6 +97,8 @@ jobs:
9197
steps:
9298
- name: Check out code
9399
uses: actions/checkout@v6
100+
with:
101+
persist-credentials: false
94102
# Run project unit tests (with the race detector enabled and atomic coverage profile collection)
95103
- name: unittests
96104
run: go test -v -race -covermode=atomic -coverprofile=profile.cov ./...

0 commit comments

Comments
 (0)