A developer asks Copilot CLI to add retry handling to a flaky deployment helper script. The script is used by a GitHub Actions job that must fail when deployment cannot be verified. Copilot proposes the following change. What should you change before accepting the proposed script? Select one answer.
#!/usr/bin/env bash
set -euo pipefail
deploy_preview() {
./scripts/deploy-preview.sh
}
for attempt in 1 2 3; do
echo "deploy attempt ${attempt}"
if deploy_preview; then
echo "deployment completed"
break
fi
echo "deployment failed, retrying"
sleep 15
done
echo "verifying preview"
curl --fail --retry 3 --retry-delay 5 "$PREVIEW_HEALTH_URL"Choose an answer
Tap an option to check your answer.
Correct answer: Add a final failure after exhausted deploy attempts.
Why this is the answer
The script currently retries the deploypreview function three times. If all attempts fail, the script will continue to execute the echo "verifying preview" line and the curl command. The curl command might then fail, but the script itself will exit successfully if the curl command eventually succeeds or if set -e is not triggered by a non-zero exit code from curl (which it will be due to --fail). However, the requirement is that the GitHub Actions job must fail if deployment cannot be verified. If all deployment attempts fail, the script should explicitly exit with a non-zero status to indicate failure to the GitHub Actions workflow. Adding a final exit 1 after the loop if deploypreview never succeeds ensures the job fails as required. Replacing curl retries with workflowdispatch is irrelevant to the script's retry logic. Moving retries to a GitHub issue comment doesn't address the script's functionality. Removing set -euo pipefail would make the script less robust, as it would ignore errors and unset variables, which is undesirable.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed