44 schedule :
55 - cron : ' 0 0 * * *' # Daily at midnight UTC
66 workflow_dispatch : # Manual trigger
7+ pull_request :
8+ branches :
9+ - dev
710
811jobs :
912 sync-and-update :
1619 - name : Checkout repository
1720 uses : actions/checkout@v4
1821 with :
19- fetch-depth : 0
22+ fetch-depth : 0 # Fetch all history for all branches and tags
2023 token : ${{ secrets.PAT_SERVICE_ACCOUNT }}
2124 ref : master
2225
@@ -37,14 +40,20 @@ jobs:
3740 fi
3841 echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
3942
40- # Update master branch
41- git fetch upstream $LATEST_TAG --depth=1
43+ # Fetch complete history from upstream
44+ git fetch upstream --unshallow || git fetch upstream
45+
46+ # Update master branch with latest release
47+ git fetch upstream $LATEST_TAG
4248 git checkout -B master FETCH_HEAD
49+
50+ # Push the updated master branch
4351 git push origin master --force
4452
45- # Count commits for tagging - this is the master branch commit count
53+ # Count all commits for tagging
4654 COMMIT_COUNT=$(git rev-list --count HEAD)
4755 echo "COMMIT_COUNT=$COMMIT_COUNT" >> $GITHUB_ENV
56+ echo "Total commits in master branch: $COMMIT_COUNT"
4857
4958 - name : Create PR to dev
5059 id : create_pr
@@ -149,17 +158,14 @@ jobs:
149158 echo "PR merged successfully!"
150159
151160 # Create tag using master branch commit count
152- TAG_NAME="$COMMIT_COUNT"
153-
154- # Checkout dev to apply the tag
155- git fetch origin dev
156- git checkout dev
161+ TAG_NAME="b$COMMIT_COUNT"
157162
158163 # Check if tag exists
159164 if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
160165 echo "Tag $TAG_NAME already exists"
161166 else
167+ # Create tag on the current commit (master branch HEAD)
162168 git tag "$TAG_NAME"
163169 git push origin "$TAG_NAME"
164- echo "Tag $TAG_NAME created successfully"
170+ echo "Tag $TAG_NAME created successfully (total commits: $COMMIT_COUNT) "
165171 fi
0 commit comments