Skip to content

Commit f32311a

Browse files
Update update-configs.yml
1 parent f0be55d commit f32311a

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

.github/workflows/update-configs.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ permissions: write-all
33

44
on:
55
schedule:
6-
- cron: '0 0 * * *'
6+
- cron: '0 0 * * *'
77
workflow_dispatch:
8+
push:
9+
branches:
10+
- main
11+
- SUB
812

913
jobs:
1014
update:
@@ -17,6 +21,7 @@ jobs:
1721
with:
1822
fetch-depth: 0
1923
token: ${{ secrets.GITHUB_TOKEN }}
24+
ref: ${{ github.ref }} # Checkout the current branch
2025

2126
- name: Setup Go
2227
uses: actions/setup-go@v5
@@ -90,18 +95,21 @@ jobs:
9095
git config user.name "GitHub Actions"
9196
git config user.email "actions@github.com"
9297
98+
# Get current branch name
99+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
100+
echo "Current branch: $CURRENT_BRANCH"
93101
94-
# Pull latest changes cleanly
95-
git pull origin main --rebase --autostash
102+
# Pull latest changes from same branch
103+
git pull origin $CURRENT_BRANCH --rebase --autostash
96104
97-
# Add freshly generated files (only if they exist)
105+
# Add freshly generated files
98106
git add config/ 2>/dev/null || true
99107
git add README.md 2>/dev/null || true
100108
101109
# Only commit if there are changes
102110
if ! git diff --staged --quiet; then
103-
git commit -m "Update configs [$(date -u '+%Y-%m-%d %H:%M UTC')]"
104-
git push origin main
111+
git commit -m "Update configs [$(date -u '+%Y-%m-%d %H:%M UTC')] - $CURRENT_BRANCH"
112+
git push origin $CURRENT_BRANCH
105113
else
106-
echo "No changes to commit"
114+
echo "No changes to commit on $CURRENT_BRANCH"
107115
fi

0 commit comments

Comments
 (0)