1
1
name : " Trigger remote Workflow"
2
2
3
+ # Workflow to trigger cicd workflow after checking trigger access.
4
+
3
5
permissions :
4
6
issues : write
5
7
id-token : write
6
8
contents : write
7
9
8
- on :
10
+ # Running after the 'Checking Labels' workflow.
11
+ on :
9
12
workflow_run :
10
13
workflows : [Checking Labels]
11
14
types : [completed]
12
15
13
- concurrency :
16
+ # Concurrency group to avoid grabbing false artifacts.
17
+ concurrency :
14
18
group : trigger-group
15
19
cancel-in-progress : false
16
20
19
23
runs-on : ubuntu-latest
20
24
steps :
21
25
22
- - name : Generate token
26
+ # generating token to trigger the pipeline in cicd repository.
27
+ - name : Generate token
23
28
id : generate_token
24
29
uses : actions/create-github-app-token@v1
25
30
with :
@@ -28,18 +33,21 @@ jobs:
28
33
owner : ${{ github.repository_owner }}
29
34
repositories : " datavault4dbt,datavault4dbt-ci-cd"
30
35
31
- - name : Checking User Identity
36
+ # Checking if creator of PR is member of internal development team.
37
+ - name : Checking User Identity
32
38
id : user_affiliation
33
39
uses : tspascoal/get-user-teams-membership@v2
34
40
with :
35
41
GITHUB_TOKEN : ${{ steps.generate_token.outputs.token }}
36
42
username : ${{ github.actor }}
37
43
team : ' Datavault4dbt Devs'
38
44
39
- - name : Outpu Team Membership
45
+ # Team Membership output for debugging
46
+ - name : Output Team Membership
40
47
run : echo "Member of datavault4dbt dev team; ${{ steps.user_affiliation.outputs.isTeamMember }}"
41
48
42
- - name : downloading-artifacts
49
+ # Grabbing the artifacts of 'checking labels' workflow.
50
+ - name : downloading-artifacts
43
51
id : download-artifact
44
52
uses : dawidd6/action-download-artifact@v6
45
53
with :
49
57
skip_unpack : false
50
58
path : ./
51
59
allow_forks : true
52
-
60
+
53
61
- name : extract-artifact
54
62
id : extract-artifact
55
63
run : |
@@ -61,12 +69,13 @@ jobs:
61
69
- name : Checkout
62
70
uses : actions/checkout@v3
63
71
64
- - name : Create a new branch based on the PR ID
72
+ - name : Create a new branch based on the PR ID
65
73
run : |
66
74
git fetch origin pull/${{ steps.extract-artifact.outputs.prid }}/head:pull/${{ steps.extract-artifact.outputs.prid }}
67
75
git push -u origin pull/${{ steps.extract-artifact.outputs.prid }}
68
76
69
- # Will only be triggered if external PRs is approved before
77
+ # Trigger the workflow if creator of PR is not a member of development team.
78
+ # Will only be triggered if external PRs is approved before.
70
79
- name : Call Workflow
71
80
if : ${{ steps.user_affiliation.outputs.isTeamMember == 'false'}}
72
81
env :
79
88
/repos/ScalefreeCOM/datavault4dbt-ci-cd/actions/workflows/reusable-workflow.yml/dispatches \
80
89
-f "ref=main" -f "inputs[pr_branch]=pull/${{ steps.extract-artifact.outputs.prid }}" -f "inputs[all_env]=true" -f "inputs[pr_id]=${{ steps.extract-artifact.outputs.prid }}" -f "inputs[remote-triggered]=true"
81
90
91
+ # Trigger workflow if member of development team added testing label to PR.
82
92
- name : trigger-labeled-workflow
83
93
if : ${{ steps.extract-artifact.outputs.labels == 'true' && steps.user_affiliation.outputs.isTeamMember == 'true'}}
84
94
env :
0 commit comments