From 873cd26ce47684c0631f7edffe4d0027cfadb694 Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Wed, 17 May 2023 12:26:17 +0100 Subject: [PATCH] Add comment to PR with preview link --- .github/workflows/preview.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index d4f8544cd8..208b597419 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -57,3 +57,27 @@ jobs: - name: Get the preview_url run: echo "url => ${{ steps.preview_step.outputs.preview_url }}" + - name: Store PR id as variable + id: pr + run: | + echo "id=$(> $GITHUB_OUTPUT + rm -f pr-id.txt + - name: Update PR status comment on success + uses: actions-cool/maintain-one-comment@v3.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + 📖 PR Preview ${{ github.sha }} has been successfully built and deployed to https://${{ steps.preview_step.outputs.preview_url }} + + body-include: '' + number: ${{ steps.pr.outputs.id }} + - name: Update PR status comment on failure + if: ${{ failure() }} + uses: actions-cool/maintain-one-comment@v3.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + 📓 💔 Deploy PR Preview failed. + + body-include: '' + number: ${{ steps.pr.outputs.id }} \ No newline at end of file