diff --git a/.github/workflows/github-pr.yml b/.github/workflows/github-pr.yml index 217803f..2c821f3 100644 --- a/.github/workflows/github-pr.yml +++ b/.github/workflows/github-pr.yml @@ -1,17 +1,28 @@ -name: PR → Discord +name: PR to Discord + on: pull_request: - types: [opened, reopened, ready_for_review] + types: [opened, reopened, ready_for_review, synchronize] + permissions: contents: read pull-requests: read jobs: notify: - # Block untrusted forks from using secrets: + # Block untrusted forks from using secrets if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} runs-on: ubuntu-latest steps: + - name: Check for Discord webhook secret + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + run: | + if [ -z "${DISCORD_WEBHOOK:-}" ]; then + echo "::notice::DISCORD_WEBHOOK secret is not set or unavailable to this run. Skipping notification." + exit 0 + fi + - name: Send embed to Discord env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} @@ -21,19 +32,46 @@ jobs: BASE: ${{ github.event.pull_request.base.ref }} HEAD: ${{ github.event.pull_request.head.ref }} run: | - payload=$(jq -n \ - --arg title "$TITLE" \ - --arg url "$URL" \ - --arg user "$USER" \ - --arg base "$BASE" \ - --arg head "$HEAD" \ - '{embeds:[{ - title:$title, - url:$url, - description:("by @" + $user), - fields:[ - {name:"Branch", value: $head + " → " + $base, inline:true} - ] - }]}) - curl -sS -X POST -H "Content-Type: application/json" \ - -d "$payload" "$DISCORD_WEBHOOK" + + # Simple JSON escaper for Bash (handles \, ", and newlines) + esc() { + local s=${1//\\/\\\\} + s=${s//\"/\\\"} + s=${s//$'\n'/\\n} + printf '%s' "$s" + } + + TITLE_ESC=$(esc "${TITLE:-New Pull Request}") + URL_ESC=$(esc "${URL:-}") + USER_ESC=$(esc "${USER:-}") + BASE_ESC=$(esc "${BASE:-}") + HEAD_ESC=$(esc "${HEAD:-}") + + # Build JSON payload safely using cat (avoids exit 1 under set -e) + payload=$(cat < ${BASE_ESC}", "inline": true } + ] + } + ] + } + EOF + ) + + # Post to Discord and require 204 No Content + http_code=$(curl -sS -o /dev/null -w "%{http_code}" \ + -X POST -H "Content-Type: application/json" \ + -d "${payload}" "$DISCORD_WEBHOOK") + + if [ "$http_code" -ne 204 ]; then + echo "::error::Discord responded with HTTP ${http_code}" + echo "Payload was: ${payload}" + exit 1 + fi diff --git a/src/app/components/SnakeCanvas.tsx b/src/app/components/SnakeCanvas.tsx index 67303f6..e4510ec 100644 --- a/src/app/components/SnakeCanvas.tsx +++ b/src/app/components/SnakeCanvas.tsx @@ -39,7 +39,10 @@ export default function SnakeCanvas() { try { a.currentTime = 0; void a.play(); - } catch {} + } catch { + // Swallow autoplay/gesture-blocked play errors intentionally + void 0; + } }, []); // random free cell based on current tuning