-
Notifications
You must be signed in to change notification settings - Fork 5
43 lines (39 loc) · 1.26 KB
/
sync-branch.yml
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
40
41
42
43
name: Sync master to current
on:
push:
branches:
- master-to-merge
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
permissions:
pull-requests: write
contents: write
jobs:
pr:
name: Submit PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: current
fetch-depth: 0
- name: Create PR
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git branch ${BRANCH_NAME} -f
git checkout ${BRANCH_NAME}
git config --global merge.ours.driver true
git merge origin/${{ github.ref_name }} -s ours
git push origin ${BRANCH_NAME} --force
PR_URL="$(gh pr list --head "${BRANCH_NAME}" --state open --json url --jq .[].url)"
if [[ -n "${PR_URL}" ]]; then
echo "PR already exists -> ${PR_URL}"
exit 0
else
gh pr create --title "Sync master to current" --body "Generated by GitHub Actions" --base current -r njzjz -a njzjz
fi
env:
GH_TOKEN: ${{ github.token }}
BRANCH_NAME: sync-master-to-current