forked from Acode-Foundation/Acode
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathon-demand-preview-releases-PR.yml
More file actions
105 lines (89 loc) · 4.05 KB
/
on-demand-preview-releases-PR.yml
File metadata and controls
105 lines (89 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: On Demand Preview Releases for PR
# avoids paths like .md, and anything in .github folder
on:
pull_request_target:
paths-ignore:
- '!*.md'
# - '.github/**'
types: [labeled, synchronize]
# defined at workflow-level as the workflow, Requires these permissions to function.
permissions:
contents: write
pull-requests: write
# All Pull Requests are issues, but not all issues are Pull Requests (like GitHub says 🙃)
issues: write
concurrency:
# Allow only one workflow per any non-`main` branch.
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
cancel-in-progress: true
jobs:
job_trigger:
name: Trigger Preview Release (if conditions met)
if: |
github.event.pull_request.draft == false
&& (github.repository_owner == 'Acode-Foundation'
&& (!contains(github.event.pull_request.labels.*.name, 'DO NOT PREVIEW RELEASE')
&& (contains(github.event.pull_request.labels.*.name, 'Bypass check - PREVIEW RELEASE')
|| contains(github.event.pull_request.labels.*.name, 'CI: RUN ON-DEMAND PREVIEW RELEASES')))
)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
clean: false
fetch-depth: 0
persist-credentials: false
# Checkout pull request HEAD commit instead of merge commit
ref: ${{ github.event.pull_request.head.sha }}
- name: Remove Manually added PR Label
if: |
contains(github.event.pull_request.labels.*.name, 'CI: RUN ON-DEMAND PREVIEW RELEASES')
run: gh pr edit $PR --remove-label "$labels"
env:
PR: ${{ github.event.pull_request.number }}
labels: 'CI: RUN ON-DEMAND PREVIEW RELEASES'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add comment to PR
uses: marocchino/sticky-pull-request-comment@v2
with:
hide_and_recreate: true
hide_classify: "OUTDATED"
header: on-demand-build-status
message: |
⚒️ Starting a workflow to build, Your On-Demand Preview Release/build for ${{ github.event.pull_request.html_url || github.event.pull_request.url }}.
status: **\`🟡 in_progress\`**
Kindly wait, this message may be updated with success or failure status.
For Owners: Please [Click here to view that github actions](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id }})/
env:
PR: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
trigger_builder:
needs: job_trigger
secrets: inherit
uses: Acode-Foundation/acode/.github/workflows/nightly-build.yml@main
with:
is_PR: true
PR_NUMBER: ${{ github.event.pull_request.number }}
skip_tagging_and_releases: true
update_Last_Comment:
needs: [job_trigger,trigger_builder]
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'Acode-Foundation' && always() && contains(fromJSON('["failure","cancelled"]'), needs.trigger_builder.result) }}
steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# clean: false
# fetch-depth: 0
- name: Update Last Comment by bot (if Workflow Triggering failed)
uses: marocchino/sticky-pull-request-comment@v2
with:
hide_and_recreate: true
hide_classify: "OUTDATED"
header: on-demand-build-status
message: |
🔴 (Workflow Trigger stopped), Your On-Demand Preview Release/build for ${{ github.event.pull_request.html_url || github.event.pull_request.url }}.
status: **${{ needs.trigger_builder.result || 'failure'}}**
---
For Owners: Please [Click here to view that github actions](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id }})