Skip to content

Commit cf26b9b

Browse files
committed
update fail safe
1 parent c896ce5 commit cf26b9b

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

.github/workflows/check-new-release.yml

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ jobs:
183183
echo "LTS_UPDATE_NEEDED=${LTS_UPDATE_NEEDED}" >> $GITHUB_OUTPUT
184184
185185
- name: Update files and create PR if needed
186+
id: update_pr
186187
if: steps.check_versions.outputs.INNOVATION_UPDATE_NEEDED == 'true' || steps.check_versions.outputs.LTS_UPDATE_NEEDED == 'true'
187188
env:
188189
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -197,10 +198,26 @@ jobs:
197198
# Generate branch name at runtime with timestamp
198199
BRANCH_NAME="bot/update-mysql-shell-$(date +%Y%m%d%H%M%S)"
199200
echo "Using branch name: $BRANCH_NAME"
200-
export BRANCH_NAME
201+
202+
# Set as output for reuse in subsequent steps
203+
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
204+
205+
# Verify that update script exists before execution
206+
if [ ! -f .github/check-new-release/scripts/update.sh ]; then
207+
echo "::error::Script .github/check-new-release/scripts/update.sh not found"
208+
exit 1
209+
fi
201210
202211
# Execute external script (without execution permission, using bash command)
212+
# and check its exit status
203213
bash .github/check-new-release/scripts/update.sh
214+
215+
# Capture exit status
216+
UPDATE_STATUS=$?
217+
if [ $UPDATE_STATUS -ne 0 ]; then
218+
echo "::error::Script update.sh exited with status $UPDATE_STATUS"
219+
exit $UPDATE_STATUS
220+
fi
204221
205222
# Show additional messages after PR creation
206223
- name: Show post-PR creation message
@@ -211,17 +228,33 @@ jobs:
211228
LTS_UPDATE_NEEDED: ${{ steps.check_versions.outputs.LTS_UPDATE_NEEDED }}
212229
LATEST_INNOVATION: ${{ steps.latest_tags.outputs.LATEST_INNOVATION }}
213230
LATEST_LTS: ${{ steps.latest_tags.outputs.LATEST_LTS }}
231+
BRANCH_NAME: ${{ steps.update_pr.outputs.BRANCH_NAME }}
214232
run: |
215-
# Use the same branch name from the previous step (if available) or regenerate it
233+
# Verify branch name is available from previous step
216234
if [ -z "$BRANCH_NAME" ]; then
235+
echo "::warning::Branch name not available from previous step"
236+
echo "Generating new branch name as fallback"
217237
BRANCH_NAME="bot/update-mysql-shell-$(date +%Y%m%d%H%M%S)"
218-
echo "Regenerated branch name: $BRANCH_NAME"
238+
echo "Generated fallback branch name: $BRANCH_NAME"
219239
else
220-
echo "Using existing branch name: $BRANCH_NAME"
240+
echo "Using branch name from previous step: $BRANCH_NAME"
221241
fi
222242
223-
# Execute external script (without execution permission, using bash command)
243+
# Verify that post-message script exists before execution
244+
if [ ! -f .github/check-new-release/scripts/post-message.sh ]; then
245+
echo "::error::Script post-message.sh not found"
246+
exit 1
247+
fi
248+
249+
# Execute external script and check its exit status
224250
bash .github/check-new-release/scripts/post-message.sh
251+
252+
# Capture exit status
253+
POST_MSG_STATUS=$?
254+
if [ $POST_MSG_STATUS -ne 0 ]; then
255+
echo "::error::Script post-message.sh exited with status $POST_MSG_STATUS"
256+
exit $POST_MSG_STATUS
257+
fi
225258
226259
# Step 6: Notification when no update is needed
227260
- name: No update needed

0 commit comments

Comments
 (0)