-
Notifications
You must be signed in to change notification settings - Fork 2
40 lines (34 loc) · 1.3 KB
/
on-pull-request.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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}