Skip to content

Commit f9b691b

Browse files
committed
Add token-permissions to CI workflow (nginx#865)
Adds permissions to the workflow and reduces number of steps
1 parent b611160 commit f9b691b

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ concurrency:
2727
env:
2828
platforms: "linux/arm64, linux/amd64"
2929

30+
permissions:
31+
contents: read
32+
3033
jobs:
3134
vars:
3235
name: Checks and variables
@@ -89,14 +92,22 @@ jobs:
8992
node-version: 18
9093
- run: npm --prefix ${{ github.workspace }}/internal/mode/static/nginx/modules install-ci-test
9194

92-
release:
93-
name: Release
95+
binary:
96+
name: Build Binary
9497
runs-on: ubuntu-22.04
95-
needs: [unit-tests, njs-unit-tests]
96-
if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }}
98+
needs: [vars, unit-tests, njs-unit-tests]
99+
permissions:
100+
contents: write # for goreleaser/goreleaser-action and lucacome/draft-release to create/update releases
97101
steps:
98102
- name: Checkout Repository
99103
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
104+
with:
105+
fetch-depth: 0
106+
107+
- name: Setup Golang Environment
108+
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
109+
with:
110+
go-version-file: go.mod
100111

101112
- name: Create/Update Draft
102113
uses: lucacome/draft-release@f6dc37dcdf44be100a649b72c62c628776750190 # v0.2.2
@@ -108,21 +119,7 @@ jobs:
108119
notes-header: |
109120
*Below is the auto-generated changelog, which includes all PRs that went into the release.
110121
For a shorter version that highlights only important changes, see [CHANGELOG.md](https://github.com/nginxinc/nginx-kubernetes-gateway/blob/{{version}}/CHANGELOG.md).*
111-
112-
binary:
113-
name: Build Binary
114-
runs-on: ubuntu-22.04
115-
needs: vars
116-
steps:
117-
- name: Checkout Repository
118-
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
119-
with:
120-
fetch-depth: 0
121-
122-
- name: Setup Golang Environment
123-
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
124-
with:
125-
go-version-file: go.mod
122+
if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }}
126123

127124
- name: Download Syft
128125
uses: anchore/sbom-action/download-syft@78fc58e266e87a38d4194b2137a3d4e9bcaf7ca1 # v0.14.3
@@ -151,6 +148,10 @@ jobs:
151148
name: Build Image
152149
runs-on: ubuntu-22.04
153150
needs: [vars, binary]
151+
permissions:
152+
contents: read # for docker/build-push-action to read repo content
153+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
154+
packages: write # for docker/build-push-action to push to GHCR
154155
steps:
155156
- name: Checkout Repository
156157
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

0 commit comments

Comments
 (0)