generated from dxw/rails-template
-
Notifications
You must be signed in to change notification settings - Fork 2
42 lines (41 loc) · 1.67 KB
/
trigger_rebase.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
name: Trigger Rebase
on:
push:
branches:
- develop
env:
AUTO_REBASE_PERSONAL_ACCESS_TOKEN: ${{ secrets.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }}
jobs:
fetch_all_prs_awaiting_automerge:
runs-on: ubuntu-latest
outputs:
pr_numbers: ${{ steps.get-all-awaiting-pr-numbers.outputs.pr_numbers }}
steps:
- name: Get all awaiting PR numbers
id: get-all-awaiting-pr-numbers
run: |
PR_NUMBERS=$(curl https://api.github.com/repos/UKGovernmentBEIS/beis-report-official-development-assistance/pulls\?state\=open | jq -c '.[] | select(.auto_merge!=null) | .number | [.]')
echo "::set-output name=pr_numbers::$PR_NUMBERS"
trigger_rebase_action:
if: ${{ needs.fetch_all_prs_awaiting_automerge.outputs.pr_numbers != '' }}
strategy:
matrix:
pr_number: ${{ fromJson(needs.fetch_all_prs_awaiting_automerge.outputs.pr_numbers) }}
needs: fetch_all_prs_awaiting_automerge
runs-on: ubuntu-latest
steps:
- name: Get the latest ref for ${{ matrix.pr_number }}
run: |
PR_DATA=$(curl https://api.github.com/repos/UKGovernmentBEIS/beis-report-official-development-assistance/pulls/${{ matrix.pr_number }})
echo "ref=$(echo $PR_DATA | jq ".head.ref") >> $GITHUB_ENV"
- name: Checkout the latest code for ${{ matrix.pr_number }}
uses: actions/checkout@v2
with:
token: ${{ secrets.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0
ref: ${{ ENV.ref }}
- name: Automatic Rebase
uses: dxw/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }}
PR_NUMBER: ${{ matrix.pr_number }}