-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (48 loc) · 1.55 KB
/
sync-dependencies.yml
File metadata and controls
56 lines (48 loc) · 1.55 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
name: "SYNC: dependencies with main"
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Check out dependencies
uses: actions/checkout@v6
with:
ref: dependencies
fetch-depth: 0
token: ${{ secrets.PUBLISH_TOKEN }}
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Try merge main
id: merge
run: |
git fetch origin main
if git merge origin/main -m "Sync main to dependencies [skip-CI]"; then
echo "result=success" >> $GITHUB_OUTPUT
else
git merge --abort
echo "result=conflict" >> $GITHUB_OUTPUT
fi
- name: Push if no conflicts
if: steps.merge.outputs.result == 'success'
run: git push origin dependencies
- name: Create PR if conflicts
if: steps.merge.outputs.result == 'conflict'
env:
GH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
run: |
existing=$(gh pr list --base dependencies --head main --json number --jq '.[0].number')
if [ -n "$existing" ]; then
echo "Sync PR #$existing already exists"
else
gh pr create --base dependencies --head main \
--title "Sync: merge main into dependencies (conflicts)" \
--body "Merge conflicts. Resolve manually."
fi