forked from asterisk/asterisk
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (74 loc) · 3.51 KB
/
OnPRStateChanged.yml
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
#
# Workflows, like this one, that are triggered by PRs submitted
# from forked repositories are severly limited in what they can do
# for security reasons. For instance, they can't add or remove
# labels or comments even on the PR that triggered them. Since
# we need to both of those things, GitHub recommends creating a
# separate workflow that does those tasks that's triggered when
# this PR workflow starts or finishes. Since that workflow isn't
# being run in the context of a forked repo, it has all the
# privileges needed to add and remove labels and comments. The
# accompanying OnPRStateChangedPriv workflow does just that.
name: PRChanged
run-name: "PR ${{ github.event.number }} ${{ github.event.action }} by ${{ github.actor }}"
on:
pull_request:
types: [opened, reopened, synchronize]
concurrency:
group: check-${{ github.event.number }}
cancel-in-progress: true
jobs:
#
# Pull requests created from forked respositories don't have access
# to the "Action Variables" ('vars' context) so we need to retrieve
# control data from an action that's located in asterisk-ci-actions.
#
Setup:
runs-on: ubuntu-latest
outputs:
vars: ${{ steps.setvars.outputs.control_data }}
testsuite_test_pr: ${{ steps.testsuitepr.outputs.testsuite_test_pr }}
steps:
- id: setvars
uses: asterisk/asterisk-ci-actions/GetRepoControlData@main
with:
repo: ${{ github.event.repository.name }}
- id: wait
env:
PR_STATE_CHANGE_DELAY_SEC: ${{ fromJSON(steps.setvars.outputs.control_data).PR_STATE_CHANGE_DELAY_SEC || 120 }}
run: |
echo "Waiting for ${PR_STATE_CHANGE_DELAY_SEC} seconds to give user a chance to add PR comments"
sleep ${PR_STATE_CHANGE_DELAY_SEC}
exit 0
- name: GetTestsuitePR
id: testsuitepr
uses: asterisk/asterisk-ci-actions/GetTestsuitePRFromAsteriskPR@main
with:
repo: ${{ github.repository }}
pr_number: ${{ github.event.number }}
testsuite_test_pr_regex: ${{ fromJSON(steps.setvars.outputs.control_data).TESTSUITE_TEST_PR_REGEX }}
testsuite_test_auto_merge_regex: ${{ fromJSON(steps.setvars.outputs.control_data).TESTSUITE_TEST_AUTO_MERGE_REGEX }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: DumpEnvironment
if: ${{ fromJSON(steps.setvars.outputs.control_data).RUN_DUMP_ENV }}
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
with:
action-vars: ${{ toJSON(steps.setvars.outputs) }}
action-inputs: ${{ toJSON(steps.testsuitepr.outputs) }}
Check:
name: Check
needs: Setup
uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskUnitGateTest.yml@main
with:
test_type: prstatechange
asterisk_repo: ${{ github.repository }}
pr_number: ${{ github.event.number }}
base_branch: ${{ github.event.pull_request.base.ref }}
build_options: ${{ fromJSON(needs.Setup.outputs.vars).BUILD_OPTIONS }}
unittest_command: ${{ fromJSON(needs.Setup.outputs.vars).UNITTEST_COMMAND }}
testsuite_repo: ${{ fromJSON(needs.Setup.outputs.vars).TESTSUITE_REPO }}
testsuite_test_pr: ${{ needs.Setup.outputs.testsuite_test_pr }}
gatetest_list: ${{ fromJSON(needs.Setup.outputs.vars).GATETEST_LIST }}
gatetest_commands: ${{ fromJSON(needs.Setup.outputs.vars).GATETEST_COMMANDS }}
secrets:
TOKEN: ${{ secrets.GITHUB_TOKEN }}