30 lines
1.2 KiB
YAML
30 lines
1.2 KiB
YAML
name: Sync Pull Request
|
|
on:
|
|
pull_request_target:
|
|
types: [labeled]
|
|
|
|
jobs:
|
|
sync_pull_request:
|
|
runs-on: ubuntu-latest
|
|
if: contains(github.event.pull_request.labels.*.name, 'ci sync')
|
|
steps:
|
|
- name: Remove label
|
|
run: |
|
|
# The label is always removed so that this action can be triggered
|
|
# again by adding the label even if the sync fails.
|
|
|
|
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X "DELETE" https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/ci%20sync
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: '0'
|
|
- name: Sync with master
|
|
run: |
|
|
set -xe
|
|
git remote add pr_remote ${{ github.event.pull_request.head.repo.html_url }}
|
|
git fetch pr_remote ${{ github.event.pull_request.head.ref }}
|
|
git checkout -b pr_branch pr_remote/${{ github.event.pull_request.head.ref }}
|
|
git config user.name github-actions
|
|
git config user.email github-actions@github.com
|
|
git merge origin/master
|
|
git push pr_remote HEAD:${{ github.event.pull_request.head.ref }}
|