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:
@@ -3,18 +3,18 @@ name: Staging deployment
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches-ignore: [main]
|
branches-ignore: [main]
|
||||||
|
pull_request:
|
||||||
|
types: [opened, reopened]
|
||||||
delete:
|
delete:
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: staging-${{ github.event.ref }}
|
group: staging-${{ github.event.pull_request.head.ref || github.event.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
pull-requests: write
|
|
||||||
env:
|
env:
|
||||||
BRANCH: ${{ github.ref_name }}
|
BRANCH: ${{ github.ref_name }}
|
||||||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
||||||
@@ -60,6 +60,28 @@ jobs:
|
|||||||
- name: Summary
|
- name: Summary
|
||||||
run: echo "Deployed to https://${HOST}" >> "$GITHUB_STEP_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
|
- name: Comment staging URL on PR
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
|
|||||||
Reference in New Issue
Block a user