From fccfe71a0f5011d3e68343087144ce0d461cd1d8 Mon Sep 17 00:00:00 2001 From: Minh141120 Date: Fri, 21 Mar 2025 10:57:14 +0700 Subject: [PATCH 1/2] ci: update tag upstream sync --- .github/workflows/upstream-sync.yml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/upstream-sync.yml b/.github/workflows/upstream-sync.yml index 48bcf75dc3990..92fd4c3a05c22 100644 --- a/.github/workflows/upstream-sync.yml +++ b/.github/workflows/upstream-sync.yml @@ -4,6 +4,9 @@ on: schedule: - cron: '0 0 * * *' # Daily at midnight UTC workflow_dispatch: # Manual trigger + pull_request: + branches: + - dev jobs: sync-and-update: @@ -16,7 +19,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 0 # Fetch all history for all branches and tags token: ${{ secrets.PAT_SERVICE_ACCOUNT }} ref: master @@ -37,14 +40,20 @@ jobs: fi echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV - # Update master branch - git fetch upstream $LATEST_TAG --depth=1 + # Fetch complete history from upstream + git fetch upstream --unshallow || git fetch upstream + + # Update master branch with latest release + git fetch upstream $LATEST_TAG git checkout -B master FETCH_HEAD + + # Push the updated master branch git push origin master --force - # Count commits for tagging - this is the master branch commit count + # Count all commits for tagging COMMIT_COUNT=$(git rev-list --count HEAD) echo "COMMIT_COUNT=$COMMIT_COUNT" >> $GITHUB_ENV + echo "Total commits in master branch: $COMMIT_COUNT" - name: Create PR to dev id: create_pr @@ -149,17 +158,14 @@ jobs: echo "PR merged successfully!" # Create tag using master branch commit count - TAG_NAME="$COMMIT_COUNT" - - # Checkout dev to apply the tag - git fetch origin dev - git checkout dev + TAG_NAME="b$COMMIT_COUNT" # Check if tag exists if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then echo "Tag $TAG_NAME already exists" else + # Create tag on the current commit (master branch HEAD) git tag "$TAG_NAME" git push origin "$TAG_NAME" - echo "Tag $TAG_NAME created successfully" + echo "Tag $TAG_NAME created successfully (total commits: $COMMIT_COUNT)" fi \ No newline at end of file From 2d0329701e8baff5daa33cf235c5db1b813830f5 Mon Sep 17 00:00:00 2001 From: Minh141120 Date: Fri, 21 Mar 2025 10:59:32 +0700 Subject: [PATCH 2/2] refactor: remove pr to main for testing --- .github/workflows/upstream-sync.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/upstream-sync.yml b/.github/workflows/upstream-sync.yml index 92fd4c3a05c22..784c14e970e8f 100644 --- a/.github/workflows/upstream-sync.yml +++ b/.github/workflows/upstream-sync.yml @@ -4,9 +4,6 @@ on: schedule: - cron: '0 0 * * *' # Daily at midnight UTC workflow_dispatch: # Manual trigger - pull_request: - branches: - - dev jobs: sync-and-update: