-
Notifications
You must be signed in to change notification settings - Fork 110
52 lines (45 loc) · 1.71 KB
/
github-action-trigger-downstream-job-reusable-workflow.yaml
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
name: Github Action reusable workflow to trigger downstream job
on:
workflow_call
jobs:
jobs01:
# Check if comment contains /trigger github-experimental
if: contains(github.event.comment.body, '/trigger github-experimental')
runs-on: [ubuntu-latest]
permissions:
pull-requests: write
outputs:
approvers_check: ${{ steps.approvers_check.outputs.approvers_check }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
sparse-checkout: |
OWNERS
sparse-checkout-cone-mode: false
ref: main
- name: Get approvers list
id: approvers_list
uses: mikefarah/yq@master
with:
cmd: yq -o=csv ".approvers" OWNERS
- name: Print Approvers list
run: echo ${{ steps.approvers_list.outputs.result }}
- name: Check commenter status
id: approvers_check
run: |
APPROVERS_CHECK=$(python -c "print('${{ github.event.comment.user.login }}' in '${{ steps.approvers_list.outputs.result }}')")
echo "approvers_check=$APPROVERS_CHECK" >> "$GITHUB_OUTPUT"
- name: Add proper labels to trigger workflow
if: steps.approvers_check.outputs.approvers_check == 'True'
uses: actions-ecosystem/action-add-labels@v1
with:
labels: |
github-experimental
- name: Print message for non approvers
if: steps.approvers_check.outputs.approvers_check == 'False'
uses: mshick/add-pr-comment@v2
with:
refresh-message-position: true
message: |
@${{ github.actor }}, You are not listed in project's approvers list. Please check with repo approvers to trigger the downstream job