Merge pull request #1107 from UKGovernmentBEIS/dependabot/npm_and_yar… #556
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rebase Automerged | |
on: | |
push: | |
branches: | |
- main | |
env: | |
AUTO_REBASE_PERSONAL_ACCESS_TOKEN: ${{ secrets.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }} | |
jobs: | |
fetch_oldest_pr_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_NUMBER=$(curl https://api.github.com/repos/UKGovernmentBEIS/regulated-professions-register/pulls\?state\=open | jq -c '[.[] | select(.auto_merge!=null) | .number] | first') | |
echo "::set-output name=pr_number::$PR_NUMBER" | |
trigger_rebase_action: | |
if: ${{ needs.fetch_oldest_pr_awaiting_automerge.outputs.pr_number != '' }} | |
env: | |
PR_NUMBER: ${{ needs.fetch_oldest_pr_awaiting_automerge.outputs.pr_number }} | |
needs: fetch_oldest_pr_awaiting_automerge | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get the latest ref for ${{ env.PR_NUMBER }} | |
run: | | |
PR_DATA=$(curl https://api.github.com/repos/UKGovernmentBEIS/regulated-professions-register/pulls/$PR_NUMBER) | |
printf 'ref=%q\n' "$(echo "$PR_DATA" | jq -r .head.ref)" >> "$GITHUB_ENV" | |
- name: Checkout the latest code for ${{ env.PR_NUMBER }} | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }} | |
fetch-depth: 0 | |
ref: ${{ env.ref }} | |
- name: Automatic Rebase | |
uses: cirrus-actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }} |