-
Notifications
You must be signed in to change notification settings - Fork 1.1k
52 lines (46 loc) · 2.15 KB
/
dispatch-pr-build.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
name: Request dispatched PR Build
on:
pull_request:
types: [ opened, reopened, synchronize, edited ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
dispatchedPR:
name: Dispatch wait and check
runs-on: ubuntu-latest
steps:
- name: Check if PR edit changed deps string
if: ${{ github.event.action == 'edited' }}
id: pr-string-changed
continue-on-error: true
run: |
old_pr_string=$(grep -P '^/(jenkins-pr-deps|jpd|prd)' <<< "$OLD_PR_BODY" | \
grep -ioP '(Graylog2/\S+?#|https?://github.com/Graylog2/\S+?/pull/)[0-9]+' || true)
new_pr_string=$(grep -P '^/(jenkins-pr-deps|jpd|prd)' <<< "$NEW_PR_BODY" | \
grep -ioP '(Graylog2/\S+?#|https?://github.com/Graylog2/\S+?/pull/)[0-9]+' || true)
if [ "$old_pr_string" != "$new_pr_string" ]; then
echo "PR deps string change detected: \"$old_pr_string\" -> \"$new_pr_string\""
echo "Re-triggering PR build..."
exit 0
fi
exit 1
env:
OLD_PR_BODY: "${{ github.event.changes.body.from }}"
NEW_PR_BODY: "${{ github.event.pull_request.body }}"
- name: Dispatch job to graylog-project-internal
if: ${{ github.event.action != 'edited' || steps.pr-string-changed.outcome == 'success' }}
run: >
gh workflow run -R Graylog2/graylog-project-internal pr-build.yml --ref master
-f caller_repo=${{ github.repository }}
-f caller_pr_nr=${{ github.event.number }}
-f caller_base_branch=${{ github.base_ref || github.ref_name }}
-f caller_head_branch=${{ github.head_ref }}
-f head_sha=${{ github.event.pull_request.head.sha }}
-f initial_actor="${{ github.actor }}/${{ github.triggering_actor }}"
env:
GITHUB_TOKEN: ${{ secrets.PAT_GRAYLOG_PROJECT_INTERNAL_WORKFLOW_RW }}
- name: Give dispatched build time to add its status
run: sleep 20
# This is mostly cosmetic. If this workflow finishes before the dispatched
# build creates the status on the PR, the build will show up green for a while.