Merge pull request #63 from KucharczykL/fix/staging-comment-on-pr-open

fix(ci): comment staging URL when the PR is opened, not just on deploy
This commit is contained in:
2026-06-21 10:51:25 +02:00
committed by GitHub
+25 -3
View File
@@ -3,18 +3,18 @@ name: Staging deployment
on:
push:
branches-ignore: [main]
pull_request:
types: [opened, reopened]
delete:
concurrency:
group: staging-${{ github.event.ref }}
group: staging-${{ github.event.pull_request.head.ref || github.event.ref }}
cancel-in-progress: true
jobs:
deploy:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
BRANCH: ${{ github.ref_name }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
@@ -60,6 +60,28 @@ jobs:
- name: Summary
run: echo "Deployed to https://${HOST}" >> "$GITHUB_STEP_SUMMARY"
# Comment the staging URL on the branch's PR. Runs both after a successful
# push-deploy (covers PRs that already exist) and when a PR is opened or
# reopened (covers the common case of pushing the branch before opening the
# PR, where the deploy ran with no PR to comment on). The comment is deduped
# by body, so the two paths never double-post.
comment:
needs: [deploy]
if: |
always() &&
(github.event_name == 'pull_request' ||
(github.event_name == 'push' && needs.deploy.result == 'success'))
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
steps:
- name: Compute staging host
run: |
SLUG=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9-]+/-/g; s/-+/-/g; s/^-//; s/-$//' | cut -c1-30 | sed 's/-*$//')
echo "HOST=timetracker-staging-${SLUG}.fly.dev" >> "$GITHUB_ENV"
- name: Comment staging URL on PR
uses: actions/github-script@v7
with: