Skip to content

Commit 152ea3e

Browse files
shoumikhinCopilot
andauthored
Implement guardrail to check for existing branches (#16132)
Added a guardrail step to prevent overwriting existing branches in the Apple workflow to avoid accidental binaries overwrite on S3. --------- Co-authored-by: Copilot <[email protected]>
1 parent a0a6278 commit 152ea3e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

.github/workflows/apple.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ jobs:
4040
run: |
4141
VERSION="1.1.0.$(TZ='PST8PDT' date +%Y%m%d)"
4242
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
43+
- name: Guardrail
44+
if: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' }}
45+
shell: bash
46+
run: |
47+
VERSION="${{ steps.set_version.outputs.version }}"
48+
BRANCH="swiftpm-${VERSION}"
49+
50+
if git ls-remote --exit-code "https://github.com/${{ github.repository }}" "refs/heads/${BRANCH}" > /dev/null 2>&1; then
51+
echo "Branch '${BRANCH}' already exists!"
52+
echo "Aborting workflow to prevent overwriting S3 binaries. The branch existence indicates this version was already published with specific checksums."
53+
echo "Please delete the remote branch '${BRANCH}' and re-run this workflow."
54+
exit 1
55+
fi
4356
4457
build-demo-ios:
4558
name: build-demo-ios

0 commit comments

Comments
 (0)