Skip to content

Commit 1423089

Browse files
authored
Merge pull request #7101 from vvoland/sync-master
sync-release-branch: Run from master against selected release
2 parents 25a1d41 + 5853360 commit 1423089

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

.github/workflows/sync-release-branch.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Sync Docker release branch
22

33
concurrency:
4-
group: ${{ github.workflow }}-${{ github.ref_name }}
4+
group: ${{ github.workflow }}-${{ inputs.release_branch }}
55
cancel-in-progress: false
66

77
permissions:
@@ -10,6 +10,10 @@ permissions:
1010
on:
1111
workflow_dispatch:
1212
inputs:
13+
release_branch:
14+
description: Release branch to sync, for example 29.x
15+
required: true
16+
type: string
1317
tag:
1418
description: Tag to sync from, for example v29.6.0
1519
required: true
@@ -25,6 +29,7 @@ jobs:
2529
runs-on: ubuntu-24.04
2630
permissions:
2731
contents: write
32+
workflows: write
2833
outputs:
2934
base_sha: ${{ steps.sync.outputs.base_sha }}
3035
has_changes: ${{ steps.sync.outputs.has_changes }}
@@ -40,9 +45,18 @@ jobs:
4045
- name: Validate
4146
env:
4247
BRANCH: ${{ github.ref_name }}
48+
RELEASE_BRANCH: ${{ inputs.release_branch }}
4349
run: |
44-
if [ "$BRANCH" = "master" ]; then
45-
echo "::error::This workflow is expected to be run on a release branch, not master"
50+
if [ "$BRANCH" != "master" ]; then
51+
echo "::error::This workflow is expected to be run on master, not $BRANCH"
52+
exit 1
53+
fi
54+
if [ "$RELEASE_BRANCH" = "master" ]; then
55+
echo "::error::The release branch must not be master"
56+
exit 1
57+
fi
58+
if ! [[ "$RELEASE_BRANCH" =~ ^[0-9]+\.[x0-9]+$ ]]; then
59+
echo "::error::Invalid release branch name: '$RELEASE_BRANCH'. Expected format: 29.x"
4660
exit 1
4761
fi
4862
@@ -55,7 +69,7 @@ jobs:
5569
id: sync
5670
env:
5771
DRY_RUN: ${{ inputs.dry_run }}
58-
RELEASE_BRANCH: ${{ github.ref_name }}
72+
RELEASE_BRANCH: ${{ inputs.release_branch }}
5973
RUN_ATTEMPT: ${{ github.run_attempt }}
6074
RUN_ID: ${{ github.run_id }}
6175
TAG: ${{ inputs.tag }}
@@ -66,9 +80,14 @@ jobs:
6680
echo "base_sha=$base_sha" >> "$GITHUB_OUTPUT"
6781
echo "temporary_branch=$temporary_branch" >> "$GITHUB_OUTPUT"
6882
83+
# Keep the master checkout unchanged so scripts run from the dispatched revision.
84+
release_worktree="$RUNNER_TEMP/release-branch"
85+
git worktree add --detach "$release_worktree" "$base_sha"
86+
cd "$release_worktree"
87+
6988
tags_file=$(mktemp)
70-
scripts/unmerged-tags \
71-
"$RELEASE_BRANCH" \
89+
"$GITHUB_WORKSPACE/scripts/unmerged-tags" \
90+
"origin/$RELEASE_BRANCH" \
7291
"$TAG" \
7392
> "$tags_file"
7493
@@ -77,7 +96,7 @@ jobs:
7796
echo >> "$GITHUB_STEP_SUMMARY"
7897
sed 's/^/- /' "$tags_file" >> "$GITHUB_STEP_SUMMARY"
7998
80-
xargs -r scripts/sync-branch < "$tags_file" | tee -a "$GITHUB_STEP_SUMMARY"
99+
xargs -r "$GITHUB_WORKSPACE/scripts/sync-branch" < "$tags_file" | tee -a "$GITHUB_STEP_SUMMARY"
81100
82101
if [[ "$DRY_RUN" == "true" ]]; then
83102
echo "has_changes=false" >> "$GITHUB_OUTPUT"
@@ -101,17 +120,18 @@ jobs:
101120
environment: docker-releases
102121
permissions:
103122
contents: write
123+
workflows: write
104124
timeout-minutes: 10
105125
steps:
106-
- name: Checkout release
126+
- name: Checkout
107127
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
108128
with:
109129
fetch-depth: 0
110130

111131
- name: Push release branch
112132
env:
113133
BASE_SHA: ${{ needs.sync-release-branch.outputs.base_sha }}
114-
RELEASE_BRANCH: ${{ github.ref_name }}
134+
RELEASE_BRANCH: ${{ inputs.release_branch }}
115135
TEMPORARY_BRANCH: ${{ needs.sync-release-branch.outputs.temporary_branch }}
116136
TEMPORARY_SHA: ${{ needs.sync-release-branch.outputs.temporary_sha }}
117137
run: |

0 commit comments

Comments
 (0)