Skip to content

Commit 0e4ee57

Browse files
committed
fix: improve exit status handling for update and post-message scripts
1 parent 20109bb commit 0e4ee57

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

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

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,26 +208,22 @@ jobs:
208208
exit 1
209209
fi
210210
211-
# Check if the script has execution permissions
211+
# Check if the script has execution permissions and capture exit status immediately
212212
if [ -x .github/check-new-release/scripts/update.sh ]; then
213213
# If executable, run directly
214214
echo "Running update.sh with execution permissions"
215215
.github/check-new-release/scripts/update.sh
216+
# Immediately capture exit status to avoid overwrites
217+
UPDATE_STATUS=$?
216218
else
217219
# If not executable, explicitly use bash
218220
echo "Running update.sh via bash (no execution permissions)"
219221
bash .github/check-new-release/scripts/update.sh
222+
# Immediately capture exit status to avoid overwrites
223+
UPDATE_STATUS=$?
220224
fi
221225
222-
# Capture exit status
223-
UPDATE_STATUS=$?
224-
if [ $UPDATE_STATUS -ne 0 ]; then
225-
echo "::error::Script update.sh exited with status $UPDATE_STATUS"
226-
exit $UPDATE_STATUS
227-
fi
228-
229-
# Capture exit status
230-
UPDATE_STATUS=$?
226+
# Check exit status
231227
if [ $UPDATE_STATUS -ne 0 ]; then
232228
echo "::error::Script update.sh exited with status $UPDATE_STATUS"
233229
exit $UPDATE_STATUS
@@ -260,30 +256,26 @@ jobs:
260256
exit 1
261257
fi
262258
263-
# Check if the script has execution permissions
259+
# Check if the script has execution permissions and capture exit status immediately
264260
if [ -x .github/check-new-release/scripts/post-message.sh ]; then
265261
# If executable, run directly
266262
echo "Running post-message.sh with execution permissions"
267263
.github/check-new-release/scripts/post-message.sh
264+
# Immediately capture exit status to avoid overwrites
265+
POST_MESSAGE_STATUS=$?
268266
else
269267
# If not executable, explicitly use bash
270268
echo "Running post-message.sh via bash (no execution permissions)"
271269
bash .github/check-new-release/scripts/post-message.sh
270+
# Immediately capture exit status to avoid overwrites
271+
POST_MESSAGE_STATUS=$?
272272
fi
273273
274-
# Capture exit status
275-
POST_MESSAGE_STATUS=$?
274+
# Check exit status
276275
if [ $POST_MESSAGE_STATUS -ne 0 ]; then
277276
echo "::error::Script post-message.sh exited with status $POST_MESSAGE_STATUS"
278277
exit $POST_MESSAGE_STATUS
279278
fi
280-
281-
# Capture exit status
282-
POST_MSG_STATUS=$?
283-
if [ $POST_MSG_STATUS -ne 0 ]; then
284-
echo "::error::Script post-message.sh exited with status $POST_MSG_STATUS"
285-
exit $POST_MSG_STATUS
286-
fi
287279
288280
# Step 6: Notification when no update is needed
289281
- name: No update needed

0 commit comments

Comments
 (0)