Skip to content

Commit fc84e79

Browse files
CI: Define Permission for Nightly & Preview Builds Workflows (Acode-Foundation#1616)
* chore: define permissions, following [ossf](https://github.com/ossf/scorecard/blob/4b2375ce6ec56d235007d960c08bd07ffc56c165/docs/checks.md#token-permissions) * fix: on-demand-preview-releases-PR RUNS on drafted Pull Requests.
1 parent 6d39b06 commit fc84e79

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.github/workflows/nightly-build.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}-${{ inputs.is_PR && 'is_PR' || 'not_PR'}}
3535
cancel-in-progress: true
3636

37+
permissions:
38+
contents: read
39+
3740
env:
3841
STORE_FILE_PATH: /tmp/app-debug.keystore
3942
BUILD_JSON_PATH: build.json
@@ -44,7 +47,13 @@
4447
timeout-minutes: 60
4548
runs-on: ubuntu-latest
4649
if: github.repository_owner == 'Acode-Foundation'
47-
50+
51+
permissions:
52+
# contents write is needed to create Nightly Releases.
53+
contents: write
54+
issues: write
55+
pull-requests: write
56+
4857
outputs:
4958
release_output_url: ${{ steps.release.outputs.url }}
5059
updated_version: ${{ steps.update-version.outputs.UPDATED_VERSION}}

.github/workflows/on-demand-preview-releases-PR.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
# - '.github/**'
88
types: [labeled, synchronize]
99

10-
10+
# defined at workflow-level as the workflow, Requires these permissions to function.
1111
permissions:
1212
contents: write
1313
pull-requests: write
@@ -23,7 +23,8 @@ jobs:
2323
job_trigger:
2424
name: Trigger Preview Release (if conditions met)
2525
if: |
26-
(github.repository_owner == 'Acode-Foundation'
26+
github.event.pull_request.draft == false
27+
&& (github.repository_owner == 'Acode-Foundation'
2728
&& (!contains(github.event.pull_request.labels.*.name, 'DO NOT PREVIEW RELEASE')
2829
&& (contains(github.event.pull_request.labels.*.name, 'Bypass check - PREVIEW RELEASE')
2930
|| contains(github.event.pull_request.labels.*.name, 'CI: RUN ON-DEMAND PREVIEW RELEASES')))

0 commit comments

Comments
 (0)