OnPRStateChanged.yml 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #
  2. # Workflows, like this one, that are triggered by PRs submitted
  3. # from forked repositories are severly limited in what they can do
  4. # for security reasons. For instance, they can't add or remove
  5. # labels or comments even on the PR that triggered them. Since
  6. # we need to both of those things, GitHub recommends creating a
  7. # separate workflow that does those tasks that's triggered when
  8. # this PR workflow starts or finishes. Since that workflow isn't
  9. # being run in the context of a forked repo, it has all the
  10. # privileges needed to add and remove labels and comments. The
  11. # accompanying OnPRStateChangedPriv workflow does just that.
  12. name: PRChanged
  13. run-name: "PR ${{ github.event.number }} ${{ github.event.action }} by ${{ github.actor }}"
  14. on:
  15. pull_request:
  16. types: [opened, reopened, synchronize]
  17. concurrency:
  18. group: check-${{ github.event.number }}
  19. cancel-in-progress: true
  20. jobs:
  21. #
  22. # Pull requests created from forked respositories don't have access
  23. # to the "Action Variables" ('vars' context) so we need to retrieve
  24. # control data from an action that's located in asterisk-ci-actions.
  25. #
  26. Setup:
  27. runs-on: ubuntu-latest
  28. outputs:
  29. vars: ${{ steps.setvars.outputs.control_data }}
  30. testsuite_test_pr: ${{ steps.testsuitepr.outputs.testsuite_test_pr }}
  31. steps:
  32. - id: setvars
  33. uses: asterisk/asterisk-ci-actions/GetRepoControlData@main
  34. with:
  35. repo: ${{ github.event.repository.name }}
  36. - id: wait
  37. env:
  38. PR_STATE_CHANGE_DELAY_SEC: ${{ fromJSON(steps.setvars.outputs.control_data).PR_STATE_CHANGE_DELAY_SEC || 120 }}
  39. run: |
  40. echo "Waiting for ${PR_STATE_CHANGE_DELAY_SEC} seconds to give user a chance to add PR comments"
  41. sleep ${PR_STATE_CHANGE_DELAY_SEC}
  42. exit 0
  43. - name: GetTestsuitePR
  44. id: testsuitepr
  45. uses: asterisk/asterisk-ci-actions/GetTestsuitePRFromAsteriskPR@main
  46. with:
  47. repo: ${{ github.repository }}
  48. pr_number: ${{ github.event.number }}
  49. testsuite_test_pr_regex: ${{ fromJSON(steps.setvars.outputs.control_data).TESTSUITE_TEST_PR_REGEX }}
  50. testsuite_test_auto_merge_regex: ${{ fromJSON(steps.setvars.outputs.control_data).TESTSUITE_TEST_AUTO_MERGE_REGEX }}
  51. github_token: ${{ secrets.GITHUB_TOKEN }}
  52. - name: DumpEnvironment
  53. if: ${{ fromJSON(steps.setvars.outputs.control_data).RUN_DUMP_ENV }}
  54. uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
  55. with:
  56. action-vars: ${{ toJSON(steps.setvars.outputs) }}
  57. action-inputs: ${{ toJSON(steps.testsuitepr.outputs) }}
  58. Check:
  59. name: Check
  60. needs: Setup
  61. uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskUnitGateTest.yml@main
  62. with:
  63. test_type: prstatechange
  64. asterisk_repo: ${{ github.repository }}
  65. pr_number: ${{ github.event.number }}
  66. base_branch: ${{ github.event.pull_request.base.ref }}
  67. build_options: ${{ fromJSON(needs.Setup.outputs.vars).BUILD_OPTIONS }}
  68. unittest_command: ${{ fromJSON(needs.Setup.outputs.vars).UNITTEST_COMMAND }}
  69. testsuite_repo: ${{ fromJSON(needs.Setup.outputs.vars).TESTSUITE_REPO }}
  70. testsuite_test_pr: ${{ needs.Setup.outputs.testsuite_test_pr }}
  71. gatetest_list: ${{ fromJSON(needs.Setup.outputs.vars).GATETEST_LIST }}
  72. gatetest_commands: ${{ fromJSON(needs.Setup.outputs.vars).GATETEST_COMMANDS }}
  73. secrets:
  74. TOKEN: ${{ secrets.GITHUB_TOKEN }}