Skip to content

Commit d131b9b

Browse files
committed
Sync auto-tag workflow with development process:
- Add pull request write permissions. - Increase timeout for tag creation job. - Implement automatic cherry-picking of release commits into development with conflict handling. - Adjust test workflow triggers for better branch handling.
1 parent 0ac2a6f commit d131b9b

2 files changed

Lines changed: 53 additions & 8 deletions

File tree

.github/workflows/auto-tag.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ on:
99

1010
permissions:
1111
contents: write
12+
pull-requests: write
1213

1314
concurrency:
1415
group: auto-tag-${{ github.ref }}
1516
cancel-in-progress: false
1617

1718
jobs:
1819
create-tag:
19-
name: Create and Push Tag
20-
# Only run when a release/* branch was actually merged (not just closed)
20+
name: Create Tag and Sync Development
2121
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
2222
runs-on: ubuntu-latest
23-
timeout-minutes: 5
23+
timeout-minutes: 10
2424

2525
steps:
2626
- name: Checkout repository
@@ -54,3 +54,39 @@ jobs:
5454
-m "Release ${{ steps.version.outputs.version }}"
5555
git push origin "${{ steps.version.outputs.tag }}"
5656
echo "::notice::Tag ${{ steps.version.outputs.tag }} pushed successfully."
57+
58+
- name: Cherry-pick release commit into development
59+
if: steps.check.outputs.exists == 'false'
60+
env:
61+
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
62+
run: |
63+
set -euo pipefail
64+
65+
RELEASE_SHA="${{ github.event.pull_request.head.sha }}"
66+
VERSION="${{ steps.version.outputs.version }}"
67+
68+
git config user.name "github-actions[bot]"
69+
git config user.email "github-actions[bot]@users.noreply.github.com"
70+
71+
git fetch origin development
72+
git checkout -B development origin/development
73+
74+
if git cherry-pick "$RELEASE_SHA"; then
75+
git push origin development
76+
echo "::notice::Cherry-pick of $RELEASE_SHA into development succeeded."
77+
else
78+
git cherry-pick --abort
79+
80+
SYNC_BRANCH="chore/sync-release-${VERSION}-to-development"
81+
git checkout -B "$SYNC_BRANCH" origin/development
82+
git push origin "$SYNC_BRANCH"
83+
84+
gh pr create \
85+
--base development \
86+
--head "$SYNC_BRANCH" \
87+
--title "chore: sync release ${VERSION} into development" \
88+
--body "$(printf 'Automatic cherry-pick of release \`%s\` (commit \`%s\`) into \`development\` failed due to conflicts.\n\nPlease apply and resolve manually:\n\n```\ngit fetch origin\ngit checkout %s\ngit cherry-pick %s\n# resolve conflicts\ngit push origin %s\n```' \
89+
"$VERSION" "$RELEASE_SHA" "$SYNC_BRANCH" "$RELEASE_SHA" "$SYNC_BRANCH")"
90+
91+
echo "::warning::Cherry-pick conflict. PR created: $SYNC_BRANCH → development."
92+
fi

.github/workflows/test.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ name: Unit Tests
22

33
on:
44
push:
5+
branches:
6+
- master
7+
- main
58
pull_request:
6-
branches: [ main, master, development ]
9+
branches:
10+
- master
11+
- main
12+
- development
713
workflow_call:
814

915
concurrency:
@@ -15,13 +21,16 @@ jobs:
1521
name: Run Tests
1622
runs-on: ubuntu-latest
1723
timeout-minutes: 20
18-
# Run on every push except normal (non-forced) pushes to master/main.
19-
# Always run when called from another workflow (workflow_call).
24+
# Run on:
25+
# - workflow_call (gate for staging + build)
26+
# - pull_request targeting development, master, or main
27+
# - force push to master/main
28+
# NOT on normal (non-forced) pushes to master/main — those are handled
29+
# by auto-tag.yml or build.yml which call this via workflow_call.
2030
if: >
2131
github.event_name == 'workflow_call' ||
2232
github.event_name == 'pull_request' ||
23-
github.event.forced == true ||
24-
(github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main')
33+
(github.event_name == 'push' && github.event.forced == true)
2534
2635
steps:
2736
- name: Checkout repository

0 commit comments

Comments
 (0)