-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (113 loc) · 4.76 KB
/
Copy pathvalidate.yaml
File metadata and controls
153 lines (113 loc) · 4.76 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#Test
name: 'PR Review Comment'
on:
issue_comment:
types: [created, edited]
jobs:
sfp-validate-pool:
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: >
github.event.issue.pull_request &&
(
contains(github.event.comment.body, '/quick-validation') ||
contains(github.event.comment.body, '/full-validation')
)
steps:
- name: Fetch Branch Name
id: fetch-branch-name
uses: xt0rted/pull-request-comment-branch@v2
- name: Check out code from ${{ steps.fetch-branch-name.outputs.head_ref }}
uses: actions/checkout@v3
with:
ref: ${{ steps.fetch-branch-name.outputs.head_ref }}
- name: Process PR Comment
id: process-comment
run: |
COMMENT_ID="${{ github.event.comment.id }}"
COMMENT_BODY="${{ github.event.comment.body }}"
echo "COMMENT_ID: $COMMENT_ID"
echo "COMMENT_BODY: $COMMENT_BODY"
echo "::set-output name=comment-id::$COMMENT_ID"
if [[ "$COMMENT_BODY" == *"/quick-validation"* ]]; then
echo "::set-output name=validation-type::quick"
elif [[ "$COMMENT_BODY" == *"/full-validation"* ]]; then
echo "::set-output name=validation-type::full"
fi
# - name: Checkout
# uses: actions/checkout@v3
- name: Run Validation
id: validate
run: |
if [[ "${{ steps.process-comment.outputs.validation-type }}" == "quick" ]]; then
echo "Running Quick Validation..."
sleep 5 # Simulate quick validation
echo "Quick Validation Successful" > result.txt
elif [[ "${{ steps.process-comment.outputs.validation-type }}" == "full" ]]; then
echo "Running Full Validation..."
sleep 60 # Simulate full validation
echo "Full Validation Successful" > result.txt
fi
continue-on-error: true
- name: Post Validation Status to PR
uses: mshick/add-pr-comment@v2
with:
message: |
Validation run completed: **${{ steps.process-comment.outputs.validation-type }}**
Status: ${{ steps.validate.outcome == 'success' && '✅ Success' || '❌ Failed' }}
[View the workflow run here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
# name: Validate and Run Commands Based on PR Labels
# on:
# pull_request:
# types: [opened, synchronize, labeled, unlabeled]
# jobs:
# validate-and-execute:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# # - name: Get PR Labels
# # id: get-labels
# # uses: actions/github-script@v6
# # with:
# # script: |
# # const labels = context.payload.pull_request.labels.map(label => label.name);
# # return labels;
# # result-encoding: string
# # - name: Determine Validation Type
# # id: determine-validation-mode
# # run: |
# # labels="${{ steps.get-labels.outputs.result }}"
# # validation_mode="thorough"
# # if echo "$labels" | grep -q "quick validation"; then
# # validation_mode="individual"
# # fi
# # echo "validation_mode=$validation_mode" | tee -a $GITHUB_OUTPUT
# # # Validate source and trigger test, skipping if there are no deployable changes
# # - name: 'If deployable changes were made, push source to a scratch org'
# # run: |
# # labels="${{ steps.get-labels.outputs.result }}"
# # validation_mode="thorough"
# # if echo "$labels" | grep -q "quick validation"; then
# # validation_mode="individual"
# # fi
# # echo $validation_mode
# - name: Get SFP Pool Validation Mode from the PR labels
# id: sfp-validation-mode
# uses: actions/github-script@v7
# with:
# script: |
# const labels = context.payload.pull_request.labels.map(label => label.name);
# const hasQuickValidation = labels.includes('quick validation');
# const hasFullValidation = labels.includes('full validation');
# let validationMode = 'thorough';
# if (hasQuickValidation && !hasFullValidation) {
# validationMode = 'individual';
# }
# console.log(`SFP Validation Mode: ${validationMode}`);
# return validationMode;
# result-encoding: string
# - name: Run Commands Based on the Validation Mode
# run: |
# echo "Running commands based on the validation mode: ${{ steps.sfp-validation-mode.outputs.result }}"