Skip to content
name: Sync Changes to Fork
on:
pull_request:
types:
- closed
jobs:
sync_fork:
if: ${{ github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
steps:
- name: Checkout foo repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Check if PR branch exists in bar repository
id: check_branch
run: |
BASE_BRANCH=${{ github.event.pull_request.base.ref }}
if git ls-remote --heads https://${{ secrets.MY_TOKEN }}@github.com/adskyiproger/poc-core-test-my.git "$BASE_BRANCH" | grep "$BASE_BRANCH"; then
echo "branch_exists=true" >> $GITHUB_ENV
else
echo "=============================================="
echo " 🚀 Branch $BASE_BRANCH doesn't exist in repository adskyiproger/poc-core-test-my"
echo " 🚪 Doing exit"
echo "=============================================="
echo "branch_exists=false" >> $GITHUB_ENV
fi
- name: Sync Fork
if: env.branch_exists == 'true'
env:
GH_TOKEN: ${{ secrets.MY_TOKEN }}
run: |
BASE_BRANCH=${{ github.event.pull_request.base.ref }}
gh repo sync adskyiproger/poc-core-test-my --branch ${BASE_BRANCH}