Skip to content

Commit aeeea8f

Browse files
authored
ci: tag the synced commit on release (#16)
The cloudnative-pg release-tag workflow now passes the release tag in the sync-api dispatch payload. Tag the freshly synced commit so the API repository keeps the same tags as cloudnative-pg, removing the manual tagging step. A release also triggers a second, tag-less sync from the push to main, so serialize the workflow with a concurrency group to avoid racing on the commit to main. Closes cloudnative-pg/cloudnative-pg#10963 Assisted-by: Claude Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent bb2ec20 commit aeeea8f

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/sync.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ on:
1212

1313
permissions: read-all
1414

15+
# A release dispatches a tag-carrying sync while the push to main triggers a
16+
# second, tag-less sync. Serialize them so they don't race on the commit to main
17+
# and the tag-carrying run tags the already-synced commit.
18+
concurrency:
19+
group: sync-api
20+
cancel-in-progress: false
21+
1522
jobs:
1623
sync:
1724
runs-on: ubuntu-latest
@@ -73,3 +80,18 @@ jobs:
7380
access_token: ${{ secrets.REPO_PAT }}
7481
branch: main
7582
enforce_admins: ${{ steps.disable_include_admins.outputs.initial_status }}
83+
84+
# When the sync is triggered by a release, the cloudnative-pg release-tag
85+
# workflow passes the release tag in the dispatch payload. Tag the freshly
86+
# synced commit so the API repository keeps the same tags as cloudnative-pg.
87+
- name: Tag the synced release
88+
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.tag != '' }}
89+
env:
90+
TAG: ${{ github.event.client_payload.tag }}
91+
run: |
92+
if git ls-remote --tags origin "refs/tags/${TAG}" | grep -q .; then
93+
echo "Tag ${TAG} already exists, nothing to do."
94+
exit 0
95+
fi
96+
git tag "${TAG}"
97+
git push origin "${TAG}"

0 commit comments

Comments
 (0)