From 6f58eb3fdebe6ae973ca71dea8892824c5b821c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Fri, 12 Jun 2026 22:26:05 +0200 Subject: [PATCH] Surface the staging URL reliably Echo the staging URL into the deploy log (not just the step summary), and comment it when a PR is opened for an already-deployed branch instead of waiting for the next push. Co-Authored-By: Claude Fable 5 --- .gitea/workflows/staging.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/staging.yml b/.gitea/workflows/staging.yml index 273c2cc..8b80160 100644 --- a/.gitea/workflows/staging.yml +++ b/.gitea/workflows/staging.yml @@ -4,6 +4,8 @@ on: push: branches-ignore: [main] delete: + pull_request: + types: [opened] jobs: deploy: @@ -72,7 +74,9 @@ jobs: "timetracker:staging-${SLUG}" - name: Summary - run: echo "Deployed to https://${HOST}" >> "$GITHUB_STEP_SUMMARY" + run: | + echo "Deployed to https://${HOST}" + echo "Deployed to https://${HOST}" >> "$GITHUB_STEP_SUMMARY" - name: Comment staging URL on PR env: @@ -97,6 +101,31 @@ jobs: "${api}/issues/${pr}/comments" >/dev/null echo "Commented staging URL on PR #${pr}" + comment: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + env: + BRANCH: ${{ github.event.pull_request.head.ref }} + PR: ${{ github.event.pull_request.number }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Comment staging URL on the new PR + run: | + SLUG=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9-]+/-/g; s/-+/-/g; s/^-//; s/-$//' | cut -c1-40) + HOST="tracker-${SLUG}.home.arpa" + auth="Authorization: token ${GITHUB_TOKEN}" + api="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}" + body="Staging deployment: https://${HOST}" + if curl -fsS -H "$auth" "${api}/issues/${PR}/comments" \ + | jq -e --arg body "$body" 'any(.[]; .body == $body)' >/dev/null; then + echo "Staging URL already commented on PR #${PR}" + exit 0 + fi + curl -fsS -X POST -H "$auth" -H 'Content-Type: application/json' \ + -d "$(jq -n --arg body "$body" '{body: $body}')" \ + "${api}/issues/${PR}/comments" >/dev/null + echo "Commented staging URL on PR #${PR}" + teardown: if: github.event_name == 'delete' && github.event.ref_type == 'branch' runs-on: ubuntu-latest