Skip to content

Bash automation scripts ​

Encyclopedia home · Search machine-readable catalog

CF-066 ​

Strict entrypoint

Copy to scripts/verify.sh.

bash
#!/usr/bin/env bash
set -euo pipefail
git diff --check
printf '%s\n' 'verification passed'

Verification. Run in a Git checkout and fail on a whitespace error.

Validation syntax-validated. Official reference

CF-067 ​

Bounded health request

Copy to scripts/smoke.sh.

bash
#!/usr/bin/env bash
set -euo pipefail
curl -fsS --max-time 6 --retry 5 --retry-connrefused "${1:?Usage: smoke.sh HEALTH_URL}"

Verification. Run against an authorized local health endpoint.

Validation syntax-validated. Official reference

CF-068 ​

Temporary state cleanup

Copy to scripts/workdir.sh.

bash
#!/usr/bin/env bash
set -euo pipefail
scratch=$(mktemp -d)
trap 'rm -rf -- "$scratch"' EXIT
printf '%s\n' ready > "$scratch/state"
test -s "$scratch/state"

Verification. The trap removes only a script-owned directory generated by mktemp.

Validation syntax-validated. Official reference

CF-069 ​

Capture first failing exit code

Copy to scripts/check.sh.

bash
#!/usr/bin/env bash
set -euo pipefail
if "$@"; then
  echo 'passed'
else
  status=$?
  printf 'failed (%s)\n' "$status" >&2
  exit "$status"
fi

Verification. Pass a trusted command and args, such as false, to prove exit code preservation.

Validation syntax-validated. Official reference

CF-070 ​

Enforce immutable reference

Copy to scripts/validate-digest.sh.

bash
#!/usr/bin/env bash
set -euo pipefail
[[ "${1:?Usage: validate-digest.sh REF}" =~ @sha256:[0-9a-f]{64}$ ]]

Verification. Verify with a valid dummy digest and an ignored tag fixture.

Validation syntax-validated. Official reference

CF-071 ​

Wait for an owned file with deadline

Copy to scripts/wait-file.sh.

bash
#!/usr/bin/env bash
set -euo pipefail
path=${1:?Usage: wait-file.sh PATH}
for attempt in {1..10}; do
  if test -s "$path"; then exit 0; fi
  sleep 1
done
printf 'Timed out: %s\n' "$path" >&2
exit 1

Verification. Use for a bounded handoff, not as a replacement for workload health.

Validation syntax-validated. Official reference

CF-072 ​

Expose source metadata

Copy to scripts/emit-version.sh.

bash
#!/usr/bin/env bash
set -euo pipefail
printf 'source_sha=%s\n' "$(git rev-parse HEAD)" >> "${GITHUB_OUTPUT:?}"

Verification. Add a step ID and read the output downstream.

Validation syntax-validated. Official reference

CF-073 ​

Checksum release files

Copy to scripts/check-release.sh.

bash
#!/usr/bin/env bash
set -euo pipefail
cd "${1:?Usage: check-release.sh DIRECTORY}"
sha256sum --strict --check SHA256SUMS

Verification. Treat the checksum list as trusted release metadata.

Validation syntax-validated. Official reference

CF-074 ​

Validate changed-service name

Copy to scripts/service-name.sh.

bash
#!/usr/bin/env bash
set -euo pipefail
case "${1:-}" in
  api|worker|frontend) printf '%s\n' "$1";;
  *) echo 'Unexpected service' >&2; exit 2;;
esac

Verification. Pass service name as an argument and verify traversal-like input is rejected.

Validation syntax-validated. Official reference

CF-075 ​

Generate UTC release timestamp

Copy to scripts/utc-release.sh.

bash
#!/usr/bin/env bash
set -euo pipefail
printf 'released_at=%s\n' "$(date -u +%FT%TZ)"

Verification. Use canonical ISO-like UTC timestamp for evidence. Verify terminal timezone doesn't affect output.

Validation syntax-validated. Official reference