diff --git a/.github/workflows/_deploy.yml b/.github/workflows/_deploy.yml index 02c123db691c..51f620a02063 100644 --- a/.github/workflows/_deploy.yml +++ b/.github/workflows/_deploy.yml @@ -38,6 +38,13 @@ jobs: permissions: id-token: write steps: + - name: Create app token + uses: actions/create-github-app-token@v3 + id: app-token + with: + client-id: ${{ vars.THEOPLAYER_BOT_APP_ID }} + private-key: ${{ secrets.THEOPLAYER_BOT_PRIVATE_KEY }} + - name: Download build artifact 🗃️ uses: actions/download-artifact@v8 with: @@ -69,3 +76,22 @@ jobs: env: CF_DISTRIBUTION_ID: ${{ vars.CF_DISTRIBUTION_ID }} PATH_TO_INVALIDATE: ${{ inputs.cf_invalidate_path }} + + - name: Add comment to Pull Request with link to preview 🕸️ + uses: actions/github-script@v9 + if: ${{ inputs.environment_name == 'preview' }} + with: + github-token: ${{ steps.app-token.outputs.token }} + script: | + const body = `| Preview | + |---| + | :rocket: View preview at: ${{ inputs.environment_url }} | + |
Deployed on ${new Date(Date.now()).toGMTString()}
| + `; + + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body + }) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 4c5d47dbbd2e..0f441de01144 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -36,6 +36,7 @@ jobs: # Do not run on PRs from Dependabot, since they should not need it. if: ${{ github.event.action != 'closed' && github.triggering_actor != 'dependabot[bot]' }} uses: ./.github/workflows/_deploy.yml + secrets: inherit with: environment_name: preview environment_url: '${{ vars.PREVIEW_CLOUDFRONT_URL }}/pr-${{ github.event.number }}/'