Skip to content

Commit 0e4d8a3

Browse files
committed
Add PR comment based validation trigger
1 parent 56c7572 commit 0e4d8a3

1 file changed

Lines changed: 123 additions & 54 deletions

File tree

.github/workflows/validate.yaml

Lines changed: 123 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,138 @@
1-
name: Validate and Run Commands Based on PR Labels
1+
name: Validate PR on Comment
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, labeled, unlabeled]
4+
issue_comment:
5+
types: [created, edited]
66

77
jobs:
8-
validate-and-execute:
8+
quick_validation:
99
runs-on: ubuntu-latest
10+
if: contains(github.event.comment.body, '/quick-validation')
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
15+
- name: Run Quick Validation
16+
run: |
17+
echo "Running Quick Validation..."
18+
# Quick validation commands go here
1019
20+
full_validation:
21+
runs-on: ubuntu-latest
22+
if: contains(github.event.comment.body, '/full-validation')
1123
steps:
1224
- name: Checkout code
1325
uses: actions/checkout@v3
26+
27+
- name: Run Full Validation
28+
run: |
29+
echo "Running Full Validation..."
30+
# Full validation commands go here
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
1453
15-
# - name: Get PR Labels
16-
# id: get-labels
17-
# uses: actions/github-script@v6
18-
# with:
19-
# script: |
20-
# const labels = context.payload.pull_request.labels.map(label => label.name);
21-
# return labels;
22-
# result-encoding: string
23-
24-
# - name: Determine Validation Type
25-
# id: determine-validation-mode
26-
# run: |
27-
# labels="${{ steps.get-labels.outputs.result }}"
28-
29-
# validation_mode="thorough"
30-
# if echo "$labels" | grep -q "quick validation"; then
31-
# validation_mode="individual"
32-
# fi
33-
34-
# echo "validation_mode=$validation_mode" | tee -a $GITHUB_OUTPUT
35-
36-
# # Validate source and trigger test, skipping if there are no deployable changes
37-
# - name: 'If deployable changes were made, push source to a scratch org'
38-
# run: |
39-
# labels="${{ steps.get-labels.outputs.result }}"
40-
41-
# validation_mode="thorough"
42-
# if echo "$labels" | grep -q "quick validation"; then
43-
# validation_mode="individual"
44-
# fi
45-
# echo $validation_mode
46-
47-
- name: Get SFP Pool Validation Mode from the PR labels
48-
id: sfp-validation-mode
49-
uses: actions/github-script@v7
50-
with:
51-
script: |
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
# name: Validate and Run Commands Based on PR Labels
71+
72+
# on:
73+
# pull_request:
74+
# types: [opened, synchronize, labeled, unlabeled]
75+
76+
# jobs:
77+
# validate-and-execute:
78+
# runs-on: ubuntu-latest
79+
80+
# steps:
81+
# - name: Checkout code
82+
# uses: actions/checkout@v3
83+
84+
# # - name: Get PR Labels
85+
# # id: get-labels
86+
# # uses: actions/github-script@v6
87+
# # with:
88+
# # script: |
89+
# # const labels = context.payload.pull_request.labels.map(label => label.name);
90+
# # return labels;
91+
# # result-encoding: string
92+
93+
# # - name: Determine Validation Type
94+
# # id: determine-validation-mode
95+
# # run: |
96+
# # labels="${{ steps.get-labels.outputs.result }}"
97+
98+
# # validation_mode="thorough"
99+
# # if echo "$labels" | grep -q "quick validation"; then
100+
# # validation_mode="individual"
101+
# # fi
102+
103+
# # echo "validation_mode=$validation_mode" | tee -a $GITHUB_OUTPUT
104+
105+
# # # Validate source and trigger test, skipping if there are no deployable changes
106+
# # - name: 'If deployable changes were made, push source to a scratch org'
107+
# # run: |
108+
# # labels="${{ steps.get-labels.outputs.result }}"
109+
110+
# # validation_mode="thorough"
111+
# # if echo "$labels" | grep -q "quick validation"; then
112+
# # validation_mode="individual"
113+
# # fi
114+
# # echo $validation_mode
115+
116+
# - name: Get SFP Pool Validation Mode from the PR labels
117+
# id: sfp-validation-mode
118+
# uses: actions/github-script@v7
119+
# with:
120+
# script: |
52121

53-
const labels = context.payload.pull_request.labels.map(label => label.name);
54-
const hasQuickValidation = labels.includes('quick validation');
55-
const hasFullValidation = labels.includes('full validation');
122+
# const labels = context.payload.pull_request.labels.map(label => label.name);
123+
# const hasQuickValidation = labels.includes('quick validation');
124+
# const hasFullValidation = labels.includes('full validation');
56125

57-
let validationMode = 'thorough';
126+
# let validationMode = 'thorough';
58127

59-
if (hasQuickValidation && !hasFullValidation) {
60-
validationMode = 'individual';
61-
}
128+
# if (hasQuickValidation && !hasFullValidation) {
129+
# validationMode = 'individual';
130+
# }
62131

63-
console.log(`SFP Validation Mode: ${validationMode}`);
64-
return validationMode;
65-
result-encoding: string
132+
# console.log(`SFP Validation Mode: ${validationMode}`);
133+
# return validationMode;
134+
# result-encoding: string
66135

67-
- name: Run Commands Based on the Validation Mode
68-
run: |
69-
echo "Running commands based on the validation mode: ${{ steps.sfp-validation-mode.outputs.result }}"
136+
# - name: Run Commands Based on the Validation Mode
137+
# run: |
138+
# echo "Running commands based on the validation mode: ${{ steps.sfp-validation-mode.outputs.result }}"

0 commit comments

Comments
 (0)