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 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 "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} | |