Skip to content

Commit efe0640

Browse files
Copilotckenst
andcommitted
Add error handling and race condition protection to deployment workflow
Co-authored-by: ckenst <6896787+ckenst@users.noreply.github.com>
1 parent 4d5ca62 commit efe0640

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ jobs:
3131
- name: Read and Increment Version
3232
id: version
3333
run: |
34+
# Check if VERSION.txt exists
35+
if [ ! -f _includes/VERSION.txt ]; then
36+
echo "ERROR: _includes/VERSION.txt not found"
37+
exit 1
38+
fi
39+
3440
# Read current version
3541
CURRENT_VERSION=$(cat _includes/VERSION.txt)
3642
echo "Current version: $CURRENT_VERSION"
@@ -64,13 +70,24 @@ jobs:
6470
git config user.name "github-actions[bot]"
6571
git config user.email "github-actions[bot]@users.noreply.github.com"
6672
git add _includes/VERSION.txt
67-
git commit -m "chore: bump version to ${{ steps.version.outputs.version }}" || echo "No changes to commit"
68-
git push
73+
74+
# Only commit and push if there are changes
75+
if git diff --staged --quiet; then
76+
echo "No changes to commit"
77+
else
78+
git commit -m "chore: bump version to ${{ steps.version.outputs.version }}"
79+
git push
80+
fi
6981
7082
- name: Create Git Tag
7183
run: |
72-
git tag -a "v${{ steps.version.outputs.version }}" -m "Release version ${{ steps.version.outputs.version }}"
73-
git push origin "v${{ steps.version.outputs.version }}"
84+
# Check if tag already exists (could happen with concurrent runs)
85+
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
86+
echo "Tag v${{ steps.version.outputs.version }} already exists, skipping tag creation"
87+
else
88+
git tag -a "v${{ steps.version.outputs.version }}" -m "Release version ${{ steps.version.outputs.version }}"
89+
git push origin "v${{ steps.version.outputs.version }}"
90+
fi
7491
7592
- name: Upload artifact
7693
uses: actions/upload-pages-artifact@v3

0 commit comments

Comments
 (0)