55 branches : [ master ]
66 workflow_dispatch :
77
8+ permissions : {}
9+
810jobs :
911
1012 # Build, test and analyze
1113 build-test-analyze :
1214 name : Build, test and analyze
1315 if : ${{ !contains(github.event.head_commit.message, '[skip test]') }}
14- uses : gh-metrics/metrics/.github/workflows/test.yml@master
16+ uses : $/.github/workflows/test.yml
17+ permissions :
18+ contents : read # Check out and test the repository.
1519
1620 # Update plugins and template indexes, along with README.md
1721 update-indexes :
1822 name : Publish rebuilt metrics indexes
1923 runs-on : ubuntu-latest
2024 needs : [build-test-analyze]
2125 permissions :
22- contents : write
26+ contents : write # Commit and push regenerated indexes.
2327 steps :
28+ # zizmor: ignore[artipacked] Credentials are required to publish regenerated files.
2429 - name : Checkout repository
25- uses : actions/checkout@v6
30+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.0
2631 with :
32+ persist-credentials : true
2733 fetch-depth : 0
2834 ref : master
2935 - name : Setup NodeJS
30- uses : actions/setup-node@v6
36+ uses : actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.0.0
3137 with :
3238 node-version : 20
3339 cache : " npm"
3440 - name : Setup metrics
3541 run : npm ci --ignore-scripts --no-audit --no-fund
3642 - name : Publish rebuild metrics indexes
43+ # zizmor: ignore[use-trusted-publishing] This publishes generated files to Git, not an npm package.
3744 run : npm run build -- publish
3845
3946 # Rebase main branch on master
@@ -42,11 +49,12 @@ jobs:
4249 runs-on : ubuntu-latest
4350 needs : [update-indexes]
4451 permissions :
45- contents : write
52+ contents : write # Merge master into and push the main branch.
4653 steps :
4754 - name : Checkout repository
48- uses : actions/checkout@v6
55+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.0
4956 with :
57+ persist-credentials : true
5058 fetch-depth : 0
5159 ref : main
5260 - name : Configure Git Identity
@@ -64,12 +72,18 @@ jobs:
6472 runs-on : ubuntu-latest
6573 needs : [update-indexes]
6674 permissions :
67- packages : write
75+ contents : read # Build the image from repository contents.
76+ packages : write # Publish master and beta container images.
6877 steps :
6978 - name : Checkout repository
70- uses : actions/checkout@v6
79+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.0
80+ with :
81+ persist-credentials : false
7182 - name : Login to GitHub registry
72- run : echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
83+ env :
84+ GITHUB_ACTOR : ${{ github.actor }}
85+ GITHUB_TOKEN : ${{ github.token }}
86+ run : echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
7387 - name : Build docker image
7488 run : docker build -t ghcr.io/gh-metrics/metrics:master .
7589 - name : Publish to GitHub registry
98112 if : github.repository_owner == 'lowlighter'
99113 steps :
100114 - name : Deploy web instance
101- run : " curl -X POST -H 'Authorization: ${{ secrets.WEB_DEPLOY_BETA_TOKEN }}' https://beta-metrics.lecoq.io/.control/stop"
115+ env :
116+ WEB_DEPLOY_TOKEN : ${{ secrets.WEB_DEPLOY_BETA_TOKEN }}
117+ run : " curl -X POST -H 'Authorization: $WEB_DEPLOY_TOKEN' https://beta-metrics.lecoq.io/.control/stop"
102118 - name : Wait for redeploy
103119 run : sleep 120
104120 - name : Check deployment status
@@ -111,7 +127,7 @@ jobs:
111127 needs : [docker-master]
112128 steps :
113129 - name : Run tests
114- uses : gh-metrics/metrics@master
130+ uses : $/
115131 with :
116132 token : MOCKED_TOKEN
117133 plugins_errors_fatal : yes
@@ -123,10 +139,10 @@ jobs:
123139 publish-examples :
124140 name : Publish examples
125141 needs : [action-master-test]
126- uses : gh-metrics/metrics/ .github/workflows/examples.yml@master
142+ uses : $/ .github/workflows/examples.yml
127143 permissions :
128- contents : write
129- packages : read
144+ contents : write # Publish generated examples.
145+ packages : read # Pull the metrics action image.
130146 secrets :
131147 METRICS_TOKEN : ${{ secrets.METRICS_TOKEN }}
132148 METRICS_TOKEN_WITH_SCOPES : ${{ secrets.METRICS_TOKEN_WITH_SCOPES }}
@@ -146,21 +162,29 @@ jobs:
146162 publish-examples-presets :
147163 name : Publish examples (presets)
148164 needs : [action-master-test]
149- uses : gh-metrics/metrics/ .github/workflows/examples.presets.yml@master
165+ uses : $/ .github/workflows/examples.presets.yml
150166 permissions :
151- contents : write
167+ contents : write # Publish generated preset examples.
152168
153169 # Build docker image from master and publish it to GitHub registry with release tag
154170 docker-release :
155171 name : Publish release to GitHub registry
156172 runs-on : ubuntu-latest
157173 needs : [publish-examples]
158174 if : contains(github.event.head_commit.message, '[release]')
175+ permissions :
176+ contents : read # Read release metadata from the repository.
177+ packages : write # Publish release and latest container images.
159178 steps :
160179 - name : Checkout repository
161- uses : actions/checkout@v6
180+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.0
181+ with :
182+ persist-credentials : false
162183 - name : Login to GitHub registry
163- run : echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
184+ env :
185+ GITHUB_ACTOR : ${{ github.actor }}
186+ GITHUB_TOKEN : ${{ github.token }}
187+ run : echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
164188 - name : Pull docker image (master)
165189 run : docker pull ghcr.io/gh-metrics/metrics:master
166190 - name : Tag docker image (release)
@@ -181,10 +205,13 @@ jobs:
181205 name : Rebase latest on master
182206 runs-on : ubuntu-latest
183207 needs : [docker-release]
208+ permissions :
209+ contents : write # Merge master into and push the latest branch.
184210 steps :
185211 - name : Checkout repository
186- uses : actions/checkout@v6
212+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.0
187213 with :
214+ persist-credentials : true
188215 fetch-depth : 0
189216 ref : latest
190217 - name : Configure Git Identity
@@ -201,9 +228,11 @@ jobs:
201228 name : Test gh-metrics/metrics@latest
202229 runs-on : ubuntu-latest
203230 needs : [update-latest]
231+ permissions :
232+ packages : read # Pull the metrics action image.
204233 steps :
205234 - name : Run tests
206- uses : gh-metrics/metrics@latest
235+ uses : gh-metrics/metrics@latest # zizmor: ignore[unpinned-uses] First-party action must test latest.
207236 with :
208237 token : MOCKED_TOKEN
209238 plugins_errors_fatal : yes
@@ -219,7 +248,9 @@ jobs:
219248 if : github.repository_owner == 'lowlighter'
220249 steps :
221250 - name : Deploy web instance
222- run : " curl -X POST -H 'Authorization: ${{ secrets.WEB_DEPLOY_TOKEN }}' https://metrics.lecoq.io/.control/stop"
251+ env :
252+ WEB_DEPLOY_TOKEN : ${{ secrets.WEB_DEPLOY_TOKEN }}
253+ run : " curl -X POST -H 'Authorization: $WEB_DEPLOY_TOKEN' https://metrics.lecoq.io/.control/stop"
223254 - name : Wait for redeploy
224255 run : sleep 120
225256 - name : Check deployment status
@@ -230,11 +261,16 @@ jobs:
230261 name : Publish release
231262 runs-on : ubuntu-latest
232263 needs : [action-latest-test, deploy-latest]
264+ permissions :
265+ contents : write # Create the GitHub release.
233266 steps :
267+ # zizmor: ignore[artipacked] Credentials are required to replace an existing release tag.
234268 - name : Checkout repository
235- uses : actions/checkout@v6
269+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.0
270+ with :
271+ persist-credentials : true
236272 - name : Setup NodeJS
237- uses : actions/setup-node@v6
273+ uses : actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.0.0
238274 with :
239275 node-version : 20
240276 cache : " npm"
0 commit comments