Compare commits

...

2 Commits

Author SHA1 Message Date
rdmclin2 51e3d16795 chore: add permissions 2026-02-11 23:03:00 +08:00
rdmclin2 5643c7815d chore: change main to dev sync workflow to canary 2026-02-11 22:55:55 +08:00
2 changed files with 46 additions and 42 deletions
@@ -0,0 +1,46 @@
name: 🔄 Branch Synchronization
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
sync-branches:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name 'lobehubbot'
git config --global user.email 'i@lobehub.com'
- name: Prepare sync branch
id: branch
run: |
echo "SYNC_BRANCH_MAIN_CANARY=sync/main-to-canary-$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: Sync main to canary
if: github.ref == 'refs/heads/main'
run: |
# Sync main to canary
git checkout main
SYNC_BRANCH_CANARY=${{ env.SYNC_BRANCH_MAIN_CANARY }}
git checkout -B $SYNC_BRANCH_CANARY
DIFF=$(git diff origin/canary...)
if [ -z "$DIFF" ]; then
echo "No changes to sync"
exit 0
fi
git push origin $SYNC_BRANCH_CANARY -f
gh pr create --base canary --head $SYNC_BRANCH_CANARY --title "Sync main branch to canary branch" --body "Automatic sync" || exit 0
env:
GH_TOKEN: ${{ github.token }}
-42
View File
@@ -1,42 +0,0 @@
name: 🔄 Branch Synchronization
on:
push:
branches:
- main
jobs:
sync-branches:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
- name: Prepare sync branch
id: branch
run: |
echo "SYNC_BRANCH_MAIN_DEV=sync/main-to-dev-$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: Sync main to dev
if: github.ref == 'refs/heads/main'
run: |
# Sync main to dev
git checkout main
SYNC_BRANCH_DEV=${{ env.SYNC_BRANCH_MAIN_DEV }}
git checkout -B $SYNC_BRANCH_DEV
DIFF=$(git diff origin/dev...)
if [ -z "$DIFF" ]; then
echo "No changes to sync"
exit 0
fi
git push origin $SYNC_BRANCH_DEV -f
gh pr create --base dev --head $SYNC_BRANCH_DEV --title "Sync main branch to dev branch" --body "Automatic sync" || exit 0
env:
GH_TOKEN: ${{ github.token }}