Skip to content

Commit

Permalink
Merge v14 into dev/v14
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdcdev committed Jul 1, 2024
2 parents c2cf4f2 + ea8d767 commit d7b2941
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/sync-branches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: 🔃 Sync branches

on:
push:
branches:
- 'v*'
workflow_dispatch:

jobs:
check-branch:
runs-on: ubuntu-latest
outputs:
is-valid-branch: ${{ steps.branch_check.outputs.is-valid-branch }}
steps:
- name: Check if branch name starts with 'v'
id: branch_check
run: |
BRANCH_NAME=${{ github.ref }}
if [[ $BRANCH_NAME =~ refs/heads/v.* ]]; then
VALID=true
else
VALID=false
fi
echo "is-valid-branch=$VALID" >> $GITHUB_OUTPUT
merge-branches:
needs: check-branch
permissions:
contents: write
if: needs.check-branch.outputs.is-valid-branch == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Merge into dev/v**
run: |
# Extract the version number from the branch name
VERSION=$(echo "${GITHUB_REF}" | sed -n 's#refs/heads/v\([0-9]\+\)#\1#p')
SOURCE_BRANCH="v${VERSION}"
TARGET_BRANCH="dev/v${VERSION}"
# Set git config
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
echo "Merging $SOURCE_BRANCH into $TARGET_BRANCH"
# Checkout the source branch
git checkout $SOURCE_BRANCH
git pull origin $SOURCE_BRANCH
echo "Pulled latest for $SOURCE_BRANCH"
# Merge into the target branch
git checkout $TARGET_BRANCH
git merge --no-ff $SOURCE_BRANCH -m "Merge v$VERSION into dev/v$VERSION"
echo "Merged $SOURCE_BRANCH into $TARGET_BRANCH"
# Push changes
git push origin $TARGET_BRANCH
echo "Pushed changes to $TARGET_BRANCH"

0 comments on commit d7b2941

Please sign in to comment.