add sync yml #7
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: 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 | |
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 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 }} |