Skip to content

Commit cffe853

Browse files
refactor(On-demand-Builds-CI)!: use pull_request_target instead of pull_request. (Acode-Foundation#1628)
* refactor(On-demand-Builds-CI)!: use pull_request_target instead of pull_request. Important: `pull_request_target` makes the `on-demand-preview-releases-PR.yml` run from base repository with secrets and gives read/write permissions to `$GITHUB_TOKEN` (`secrets.GITHUB_TOKEN`). Unlike normal `pull_request` trigger that has explicit read-ONLY permissions for `$GITHUB_TOKEN`. Meaning secrets and permissions SHOULD BE NOW handled strictly! Changes: - checkout `${{ github.event.pull_request.head.sha }}` & sets `persist-credentials: false` to not persist tokens in local git config. - Adds `skip_tagging_and_releases` input for nightly-build.yml Manual Runs (default: true) - Adds `CODEOWNERS` file to protect nightly builds and on demand workflows, preventing pushes in PRs without reviews from Authors of the workflow. * chore: remove `\n\n` from nightly release notes. * revert(nightly-build): partial file - Acode-Foundation@2c37532 Revert: Acode-Foundation@2c37532 for: Acode-Foundation#1628 (comment) ( @peasneovoyager2banana2) as they did Acode-Foundation#1627 before. With All Respect! * add(nightly-build): ref & persist-credentials
1 parent 2b5ebcf commit cffe853

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.github/CODEOWNERS @Acode-Foundation
2+
3+
# workflows
4+
.github/workflows/nightly-build.yml @unschooledgamer
5+
.github/workflows/on-demand-preview-releases-PR.yml @unschooledgamer
6+
.github/workflows/community-release-notifier.yml @unschooledgamer

.github/workflows/nightly-build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Implement to use environment secrets someday, At the moment GH Actions doesn't support those in reusable workflows (ref: https://github.com/actions/runner/issues/1490)
2+
# at least that's what I found.
13
name: Nightly Build
24

35
on:
@@ -28,6 +30,12 @@
2830
value: ${{ jobs.build.result }}
2931

3032
workflow_dispatch:
33+
inputs:
34+
skip_tagging_and_releases:
35+
required: false
36+
default: true
37+
type: boolean
38+
description: Skips Tagging & releases, since workflow_call isn't available for github.event_name, default is true
3139

3240
concurrency:
3341
# Allow only one workflow per any non-`main` branch.
@@ -51,7 +59,7 @@
5159
permissions:
5260
# contents write is needed to create Nightly Releases.
5361
contents: write
54-
issues: write
62+
# issues: write
5563
pull-requests: write
5664

5765
outputs:
@@ -89,13 +97,15 @@
8997
uses: actions/checkout@v4
9098
with:
9199
fetch-depth: 0 # Required for tags
100+
persist-credentials: false
101+
ref: (inputs.is_PR && inputs.PR_NUMBER) && github.event.pull_request.head.sha || ''
92102

93103
- name: Set up Java 21
94104
uses: actions/setup-java@v4
95105
with:
96106
distribution: 'temurin'
97107
java-version: '21'
98-
cache: ${{ (github.ref == 'refs/heads/main' && 'gradle') || '' }}
108+
cache: ${{ (!(inputs.is_PR && inputs.PR_NUMBER) && github.ref == 'refs/heads/main' && 'gradle') || '' }}
99109

100110
- name: Set up Node.js
101111
uses: actions/setup-node@v4

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: On Demand Preview Releases for PR
22
# avoids paths like .md, and anything in .github folder
33
on:
4-
pull_request:
4+
pull_request_target:
55
paths-ignore:
66
- '!*.md'
77
# - '.github/**'
@@ -38,6 +38,9 @@ jobs:
3838
with:
3939
clean: false
4040
fetch-depth: 0
41+
persist-credentials: false
42+
# Checkout pull request HEAD commit instead of merge commit
43+
ref: ${{ github.event.pull_request.head.sha }}
4144

4245
- name: Remove Manually added PR Label
4346
if: |

0 commit comments

Comments
 (0)