Skip to content

Commit ceda7fa

Browse files
committed
+changelog-ignore: sync branches
1 parent 45207fd commit ceda7fa

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: 🔃 Sync branches
2+
3+
on:
4+
push:
5+
branches:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
check-branch:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
is-valid-branch: ${{ steps.branch_check.outputs.is-valid-branch }}
14+
steps:
15+
- name: Check if branch name starts with 'v'
16+
id: branch_check
17+
run: |
18+
BRANCH_NAME=${{ github.ref }}
19+
if [[ $BRANCH_NAME =~ refs/heads/v.* ]]; then
20+
VALID=true
21+
else
22+
VALID=false
23+
fi
24+
25+
echo "is-valid-branch=$VALID" >> $GITHUB_OUTPUT
26+
merge-branches:
27+
needs: check-branch
28+
permissions:
29+
contents: write
30+
if: needs.check-branch.outputs.is-valid-branch == 'true'
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
- name: Merge into dev/v**
38+
run: |
39+
# Extract the version number from the branch name
40+
VERSION=$(echo "${GITHUB_REF}" | sed -n 's#refs/heads/v\([0-9]\+\)#\1#p')
41+
SOURCE_BRANCH="v${VERSION}"
42+
TARGET_BRANCH="dev/v${VERSION}"
43+
# Set git config
44+
git config user.name "${{ github.actor }}"
45+
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
46+
47+
48+
echo "Merging $SOURCE_BRANCH into $TARGET_BRANCH"
49+
50+
# Checkout the source branch
51+
git checkout $SOURCE_BRANCH
52+
git pull origin $SOURCE_BRANCH
53+
echo "Pulled latest for $SOURCE_BRANCH"
54+
55+
# Merge into the target branch
56+
git checkout $TARGET_BRANCH
57+
git merge --no-ff $SOURCE_BRANCH -m "Merge v$VERSION into dev/v$VERSION"
58+
echo "Merged $SOURCE_BRANCH into $TARGET_BRANCH"
59+
60+
# Push changes
61+
git push origin $TARGET_BRANCH
62+
echo "Pushed changes to $TARGET_BRANCH"
63+

0 commit comments

Comments
 (0)