Skip to content

Commit 8bff35d

Browse files
committed
fix(ci): proper permissions for main CI
Signed-off-by: Emilien Escalle <[email protected]>
1 parent 0ba1c43 commit 8bff35d

File tree

3 files changed

+75
-4
lines changed

3 files changed

+75
-4
lines changed

.ghadocs.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"paths": {
3+
"action": "action.yml",
4+
"readme": "README.md"
5+
},
6+
"show_logo": true,
7+
"versioning": {
8+
"enabled": true,
9+
"override": "",
10+
"prefix": "v",
11+
"branch": "main"
12+
},
13+
"owner": "hoverkraft-tech",
14+
"repo": "ci-gitHub-common",
15+
"title_prefix": "GitHub Action: ",
16+
"prettier": true
17+
}

.github/workflows/__main-ci.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ on:
77
workflow_dispatch:
88

99
permissions:
10-
contents: read
10+
contents: write
11+
packages: read
12+
statuses: write
13+
actions: write
14+
pull-requests: write
15+
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
16+
id-token: write
1117

1218
concurrency:
1319
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/release-actions.yml

+51-3
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,35 @@ jobs:
125125
fail-fast: false
126126
matrix:
127127
action: ${{ fromJson(needs.prepare-release.outputs.changed-actions) }}
128+
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
129+
permissions:
130+
contents: read
131+
id-token: write
128132
steps:
129133
- uses: actions/checkout@v4
134+
135+
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
136+
# jscpd:ignore-start
137+
- id: oidc
138+
uses: ChristopherHX/oidc@v3
139+
- uses: actions/checkout@v4 # checks out called workflow
140+
with:
141+
path: ./self-workflow
142+
repository: ${{ steps.oidc.outputs.job_workflow_repo_name_and_owner }}
143+
ref: ${{ steps.oidc.outputs.job_workflow_repo_ref }}
144+
# jscpd:ignore-end
145+
146+
- id: action-slug
147+
uses: ./self-workflow/actions/slugify
148+
with:
149+
value: ${{ matrix.action }}
150+
151+
- run: |
152+
jq '.paths.action = "${{ matrix.action }}/action.yml"' .ghadocs.json > .ghadocs.json.tmp
153+
mv .ghadocs.json.tmp .ghadocs.json
154+
155+
jq '.paths.readme = "${{ matrix.action }}/README.md"' .ghadocs.json > .ghadocs.json.tmp
156+
mv .ghadocs.json.tmp .ghadocs.json
130157
131158
- name: 📖 Generate README
132159
uses: bitflight-devops/[email protected]
@@ -144,7 +171,7 @@ jobs:
144171

145172
- uses: actions/upload-artifact@v4
146173
with:
147-
name: changed-files
174+
name: changed-files-${{ steps.action-slug.outputs.result }}
148175
path: ${{ github.workspace }}/**/${{ matrix.action }}/README.md
149176

150177
generate-workflows-readme:
@@ -155,9 +182,29 @@ jobs:
155182
fail-fast: false
156183
matrix:
157184
workflow: ${{ fromJson(needs.prepare-release.outputs.changed-workflows) }}
185+
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
186+
permissions:
187+
contents: read
188+
id-token: write
158189
steps:
159190
- uses: actions/checkout@v4
160191

192+
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
193+
# jscpd:ignore-start
194+
- id: oidc
195+
uses: ChristopherHX/oidc@v3
196+
- uses: actions/checkout@v4 # checks out called workflow
197+
with:
198+
path: ./self-workflow
199+
repository: ${{ steps.oidc.outputs.job_workflow_repo_name_and_owner }}
200+
ref: ${{ steps.oidc.outputs.job_workflow_repo_ref }}
201+
# jscpd:ignore-end
202+
203+
- id: workflow-slug
204+
uses: ./self-workflow/actions/slugify
205+
with:
206+
value: ${{ matrix.workflow }}
207+
161208
- name: 📖 Generate README
162209
id: generate-readme
163210
run:
@@ -173,7 +220,7 @@ jobs:
173220

174221
- uses: actions/upload-artifact@v4
175222
with:
176-
name: changed-files
223+
name: changed-files-${{ steps.workflow-slug.outputs.result }}
177224
path: ${{ github.workspace }}/**/${{ steps.generate-readme.outputs.readme-file }}
178225

179226
publish-actions-readme:
@@ -191,7 +238,8 @@ jobs:
191238

192239
- uses: actions/download-artifact@v4
193240
with:
194-
name: changed-files
241+
pattern: changed-files-*
242+
merge-multiple: true
195243

196244
- uses: actions/create-github-app-token@v1
197245
if: inputs.github-app-id

0 commit comments

Comments
 (0)