File tree Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Sync default branches
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ - master
8
+ pull_request :
9
+ paths :
10
+ - .github/workflows/sync-default-branches.yml
11
+
12
+ permissions : {}
13
+
14
+ defaults :
15
+ run :
16
+ shell : bash -xeuo pipefail {0}
17
+
18
+ concurrency :
19
+ group : " sync-default-branches-${{ github.ref }}"
20
+ cancel-in-progress : true
21
+
22
+ jobs :
23
+ sync :
24
+ runs-on : ubuntu-latest
25
+ permissions :
26
+ contents : write
27
+ steps :
28
+ - name : Configure Git user
29
+ uses : Homebrew/actions/git-user-config@main
30
+ with :
31
+ username : github-actions[bot]
32
+
33
+ - name : Determine source and target branches
34
+ id : branches
35
+ run : |
36
+ if [[ "${GITHUB_REF_NAME}" == "main" ]]; then
37
+ target="master"
38
+ source="main"
39
+ else
40
+ target="main"
41
+ source="master"
42
+ fi
43
+ echo "target=${target}" >> "$GITHUB_OUTPUT"
44
+ echo "source=${source}" >> "$GITHUB_OUTPUT"
45
+
46
+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47
+ with :
48
+ fetch-depth : 0
49
+ persist-credentials : true
50
+
51
+ - name : Setup target branch
52
+ run : |
53
+ git checkout "${TARGET_BRANCH}" || git checkout -b "${TARGET_BRANCH}"
54
+ git reset --hard "origin/${SOURCE_BRANCH}"
55
+ env :
56
+ SOURCE_BRANCH : ${{ steps.branches.outputs.source }}
57
+ TARGET_BRANCH : ${{ steps.branches.outputs.target }}
58
+
59
+ - name : Push target branch
60
+ if : github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
61
+ run : git push origin "${TARGET_BRANCH}" --force-with-lease
62
+ env :
63
+ TARGET_BRANCH : ${{ steps.branches.outputs.target }}
You can’t perform that action at this time.
0 commit comments