11
22on :
33 pull_request :
4- types : [labeled]
4+ types : [synchronize, opened, reopened, labeled]
55
66permissions :
77 pull-requests : write
@@ -10,11 +10,14 @@ concurrency:
1010 group : ${{ github.workflow }}-${{ github.ref }}
1111 cancel-in-progress : true
1212
13+ env :
14+ FULL_VALIDATION_LABEL : ' full validation'
15+ QUICK_VALIDATION_LABEL : ' quick validation'
1316
1417jobs :
1518 validate :
1619 name : ' Validate Changed Packages'
17- if : contains(github.event.pull_request.labels.*.name, 'full validation')
20+ if : github.event.action == 'labeled' && contains(github.event.pull_request.labels.*.name, 'full validation')
1821 runs-on : ubuntu-latest
1922
2023 steps :
@@ -31,20 +34,59 @@ jobs:
3134 sleep 30
3235 exit 0
3336
34- - name : Remove label
37+ - name : ' Remove label'
3538 if : always()
3639 run : |
3740 PR_NUMBER=${{ github.event.pull_request.number }}
3841 REPO=${{ github.repository }}
3942 LABEL="full validation"
4043
4144 # URL-encodes the label by replacing special characters with their percent-encoded equivalents.
42- ENCODED_LABEL =$(printf "%s" "$LABEL " | sed -e 's/ /%20/g' -e 's/:/%3A/g' -e 's/\//%2F/g' -e 's/?/%3F/g' -e 's/&/%26/g' -e 's/=/%3D/g')
45+ ENCODED_FULL_VALIDATION_LABEL =$(printf "%s" "${{ env.FULL_VALIDATION_LABEL }} " | sed -e 's/ /%20/g' -e 's/:/%3A/g' -e 's/\//%2F/g' -e 's/?/%3F/g' -e 's/&/%26/g' -e 's/=/%3D/g')
4346
44- echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$ENCODED_LABEL "
47+ echo "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_FULL_VALIDATION_LABEL} "
4548 curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
4649 -H "Accept: application/vnd.github.v3+json" \
47- "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_LABEL}"
50+ "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/${ENCODED_FULL_VALIDATION_LABEL}"
51+
52+ static-check :
53+ name : ' See if Static Analysis should run'
54+ if : github.event.action == 'synchronize' || github.event.action == 'opened' || github.event.action == 'reopened'
55+ runs-on : ubuntu-latest
56+
57+ outputs :
58+ all-changed-files : ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
59+
60+ steps :
61+ - uses : actions/checkout@v4
62+ with :
63+ fetch-depth : 0
64+
65+ - name : Get all changed files for this PR
66+ id : changed-files
67+ run : |
68+ # Simulating output for debugging purposes
69+ echo "all_changed_and_modified_files=file1.txt,file2.txt,file3.txt"
70+ echo "::set-output name=all_changed_and_modified_files::file1.txt,file2.txt,file3.txt"
71+
72+ - name : List changed files, skipping this job if there are no files to analyze
73+ run : |
74+ if [ "${{ steps.changed-files.outputs.all_changed_and_modified_files }}" == "" ]; then
75+ echo 'No files eligible for scanning were changed. Skipping Static Analysis.'
76+ exit 0
77+ else
78+ echo ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
79+ fi
80+
81+ static :
82+ name : ' Run Static Analysis'
83+ runs-on : ubuntu-latest
84+ needs : static-check
85+ if : needs.static-check.outputs.all-changed-files != ''
86+
87+ steps :
88+ - name : Check the outputs to determine whether to fail
89+ run : echo "Running static analyzer"
4890
4991# remove-label:
5092# needs: validate
0 commit comments