From e53ac625defc654250d842482c188f1f0203b8b3 Mon Sep 17 00:00:00 2001 From: Jamie Ruderman Date: Sat, 24 Oct 2026 09:21:30 -0700 Subject: [PATCH] ci(amplify): comment the branch preview link on feat and fix PRs --- .github/workflows/preview-link.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/preview-link.yml diff --git a/.github/workflows/preview-link.yml b/.github/workflows/preview-link.yml new file mode 100644 index 000000000..66a525d91 --- /dev/null +++ b/.github/workflows/preview-link.yml @@ -0,0 +1,26 @@ +name: Preview link + +# Amplify's branch previews (readme, "Sign-in (permitteer OIDC)") post nothing to the PR, unlike the +# pull request previews they replaced, so this comments the branch's address once. +on: + pull_request: + types: [opened, reopened] + +permissions: + pull-requests: write + +jobs: + comment: + if: github.event.pull_request.head.repo.full_name == github.repository && (startsWith(github.head_ref, 'feat/') || startsWith(github.head_ref, 'fix/')) + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + with: + script: | + const marker = '' + const {owner, repo} = context.repo + const issue_number = context.payload.pull_request.number + const comments = await github.paginate(github.rest.issues.listComments, {owner, repo, issue_number}) + if (comments.some(comment => comment.body?.includes(marker))) return + const url = `https://${context.payload.pull_request.head.ref.replace(/\//g, '-')}.d20k671nqqv4kl.amplifyapp.com` + await github.rest.issues.createComment({owner, repo, issue_number, body: `${marker}\nAmplify branch preview (ready once the build finishes): ${url}`})