-
-
Notifications
You must be signed in to change notification settings - Fork 76
84 lines (66 loc) · 2.69 KB
/
update-develop-branch.yml
File metadata and controls
84 lines (66 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Update Develop Branch
on:
push:
branches: [ master ]
permissions:
contents: write
jobs:
update-develop:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v6
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Update develop branch
run: |
# Configure git with GitHub Actions bot credentials
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# Ensure we have the latest remote refs
git fetch origin
# Check if develop branch exists locally, if not create it
if git show-ref --verify --quiet refs/heads/develop; then
echo "Local develop branch exists, checking it out"
git checkout develop
else
echo "Local develop branch doesn't exist, creating from remote"
git checkout -b develop origin/develop
fi
# Reset develop to master
echo "Resetting develop branch to match master..."
git reset --hard origin/master
# Read current version and bump patch
CURRENT_VERSION=$(cat VERSION)
echo "Current version: $CURRENT_VERSION"
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}-develop1"
echo "New version: $NEW_VERSION"
# Update VERSION file
echo "$NEW_VERSION" > VERSION
# Check if there are changes to commit
if git diff --quiet; then
echo "No changes to commit"
exit 0
fi
# Commit the change
git add VERSION
git commit -m "Update VERSION to $NEW_VERSION [skip ci]"
# Push develop branch (force push since we reset to master)
# Note: This requires PAT_TOKEN secret with admin privileges to bypass branch protection
echo "Pushing changes to develop branch..."
if ! git push --force origin develop; then
echo "Failed to push to develop branch. This may be due to branch protection rules."
echo "Ensure PAT_TOKEN secret is set with admin privileges or disable branch protection for this workflow."
exit 1
fi
echo "Successfully updated develop branch to $NEW_VERSION"
- name: Trigger develop workflow
if: success()
run: |
echo "Triggering develop workflow..."
gh workflow run develop.yml --ref develop
env:
GH_TOKEN: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}