Files
Calixte Denizet 55a90eb91f Extract viewer preview checks and preparation into scripts
Run preview scripts directly, use timestamps for the deployment timeout,
and remove .nojekyll creation and the jq availability check. Allow the
preview scripts to keep their executable bit in lint-chmod.
2026-10-06 21:21:14 +02:00

21 lines
651 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
: "${GH_TOKEN:?}"
: "${GITHUB_REPOSITORY:?}"
: "${PR:?}"
: "${BODY:?}"
marker="<!-- viewer-preview -->"
comment_id="$(gh api --paginate "repos/${GITHUB_REPOSITORY}/issues/${PR}/comments" \
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"${marker}\"))) | .id" |
tail -n1)"
if [ -n "$comment_id" ]; then
gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${comment_id}" \
--method PATCH -F "body=@${BODY}" --silent
elif [ "${CREATE:-true}" = true ]; then
gh api "repos/${GITHUB_REPOSITORY}/issues/${PR}/comments" \
--method POST -F "body=@${BODY}" --silent
fi