11name : Main workflow
22
3+
4+ # The handling of the workflow trigger is done by the lauch job !!
35on :
46 push :
5- branches :
6- - main
7- - develop
8- pull_request : # this will trigger also on syncronize (when pull request is updated)
9-
10-
11-
127
138jobs :
14- workflow-trigger :
15- if : |
16- github.ref == 'refs/heads/main' ||
17- github.ref == 'refs/heads/develop' ||
18- github.event_name == 'push' ||
19- github.event_name == 'pull_request' ||
20- github.event_name == 'workflow_dispatch'
21- runs-on : ubuntu-latest
22- steps :
23- - name : Trigger detected
24- run : echo "Trigger detected"
25- - name : Print pull request labels
26- run : |
27- if [[ -n "${{ github.event.pull_request }}" ]]; then
28- echo "Pull request labels: ${{ toJson(github.event.pull_request.labels) }}"
29- echo "Pull request number: ${{ toJson(github.event.pull_request) }}"
30- else
31- echo "no PR is linked"
32- fi
33- - name : Print commit message
34- run : |
35- if [[ -n "${{ github.event.head_commit.message }}" ]]; then
36- echo "Commit message: ${{ github.event.head_commit.message }}"
37- else
38- echo "no commit message"
39- fi
40- - name : Print event name
41- run : |
42- if [[ -n "${{ github.event_name }}" ]]; then
43- echo "Event name: ${{ github.event_name }}"
9+ scan-pr-labels :
10+ runs-on : ubuntu-latest
11+ # Map a step output to a job output
12+ outputs :
13+ output1 : ${{ steps.ispresent.outputs.labelispresent }}
14+ steps :
15+ - uses : 8BitJonny/gh-get-current-pr@3.0.0
16+ id : PR
17+ with :
18+ # Authetication token to access GitHub APIs. (Can be omitted by default.)
19+ github-token : ${{ github.token }}
20+ # Verbose setting SHA when using Pull_Request event trigger to fix #16. (For push even trigger this is not necessary.)
21+ sha : ${{ github.sha }}
22+
23+ - id : ispresent
24+ env :
25+ prLabel : ${{ steps.PR.outputs.pr_labels }}
26+ run : |
27+ if [[ "$prLabel" == *"RUN TESTS"* ]]; then
28+ echo "The label 'RUN TESTS' is present."
29+ echo "labelispresent=1" >> "$GITHUB_OUTPUT"
4430 else
45- echo "no event name"
31+ echo "The label 'RUN TESTS' is not present."
32+ echo "labelispresent=0" >> "$GITHUB_OUTPUT"
4633 fi
4734
35+ launch-pipeline :
36+ runs-on : ubuntu-latest
37+ needs : scan-pr-labels
38+ if :
39+ github.ref == 'refs/heads/main' ||
40+ github.ref == 'refs/heads/develop' ||
41+ github.event_name == 'pull_request' ||
42+ github.event_name == 'workflow_dispatch' ||
43+ needs.scan-pr-labels.outputs.output1 == '1'
44+ env :
45+ OUTPUT1 : ${{ needs.scan-pr-labels.outputs.output1 }}
46+
47+ steps :
48+ - env :
49+ OUTPUT1 : ${{needs.job1.outputs.output1}}
50+ run : echo "Conditions are met, proceeding with the workflow!""
51+
52+
53+
4854 build-package :
49- needs : workflow-trigger
55+ needs : launch-pipeline
5056 runs-on : ubuntu-latest
5157 steps :
5258 - name : Checkout code
@@ -245,7 +251,7 @@ jobs:
245251
246252 versiontest :
247253 name : check if version is valid
248- needs : workflow-trigger
254+ needs : launch-pipeline
249255 runs-on : ubuntu-latest
250256 steps :
251257 - uses : actions/checkout@v3
@@ -266,7 +272,7 @@ jobs:
266272
267273 pytest :
268274 name : Run Pytest framework
269- needs : workflow-trigger
275+ needs : launch-pipeline
270276 runs-on : ubuntu-latest
271277 # Dynamically create a matrix of test files
272278 strategy :
0 commit comments