Skip to content

add sync yml

add sync yml #8

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:
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
with:
path: main
- name: Checkout subnet-evm repo
uses: actions/checkout@v3
with:
repository: ava-labs/subnet-evm
path: subnet-evm
- name: Prepare branch for push
run: |
new_branch="${{ github.event.pull_request.head.ref }}-coreth"
git stash
git checkout subnet-evm/$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 subnet-evm/$TARGET_BRANCH -- .github
git add .
git commit -m "remove changes to .github/ directory"
git push subnet-evm ${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 }}