Skip to content

add sync yml

add sync yml #6

name: Sync PRs between Repos
on:
pull_request:
# TODO: remove those after testimg
types:
- opened
- closed
- synchronize
- reopened
# TODO: uncomment this after testimg
# branches:
# - 'master'
paths-ignore:
- '.github/**'
- '**.md'
env:
TARGET_REPO: https://github.com/ava-labs/subnet-evm.git
SOURCE_BRANCH: master
TARGET_BRANCH: master
jobs:
sync_pr:
# TODO: uncomment after testing
# if: github.event.pull_request.merged == true
if: |
!contains(github.event.pull_request.labels.*.name, 'do not sync')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set Git Identity
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Prepare branch for push
run: |
git remote add syncrepo $TARGET_REPO
git fetch syncrepo $TARGET_BRANCH
new_branch="${{ github.event.pull_request.head.ref }}-coreth"
git checkout syncrepo/$TARGET_BRANCH
git checkout -b "${new_branch}"
git cherry-pick ${{ github.event.pull_request.head.sha }} || true
git add .
git cherry-pick --continue --no-edit
git checkout syncrepo/$TARGET_BRANCH -- .github
git add .
git commit -m "remove changes to .github/ directory"
git push syncrepo ${new_branch}
- name: Create PR in Repo Subnet-EVM
run: |
gh pr create \
--repo ava-labs/subnet-evm \
--title "${{ github.event.pull_request.title }}" \
--body "This PR was automatically created to sync changes from Coreth.\n\nOriginal PR: ${{ github.event.pull_request.html_url }}\n\n---\n\n${{github.event.pull_request.body}}" \
--base $TARGET_BRANCH \
--head ${{ github.event.pull_request.head.ref }}-coreth \
--assignee "${{ github.event.pull_request.user.login }}" \
--draft=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}