|
7 | 7 | types: |
8 | 8 | - completed |
9 | 9 | jobs: |
10 | | - build: |
| 10 | + deploy: |
11 | 11 | runs-on: ubuntu-latest |
12 | | - if: > |
13 | | - ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }} |
| 12 | + if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' |
14 | 13 | steps: |
15 | 14 | - name: "🔍 Read PR number" |
16 | 15 | id: readctx |
17 | | - # we need to find the PR number that corresponds to the branch, which we do by |
18 | | - # searching the GH API |
| 16 | + # We need to find the PR number that corresponds to the branch, which we do by searching the GH API |
19 | 17 | # The workflow_run event includes a list of pull requests, but it doesn't get populated for |
20 | 18 | # forked PRs: https://docs.github.com/en/rest/reference/checks#create-a-check-run |
21 | 19 | run: | |
22 | 20 | head_branch='${{github.event.workflow_run.head_repository.owner.login}}:${{github.event.workflow_run.head_branch}}' |
23 | | - echo "head branch: $head_branch" |
| 21 | + echo "Head branch: $head_branch" |
24 | 22 | pulls_uri="https://api.github.com/repos/${{ github.repository }}/pulls?head=$(jq -Rr '@uri' <<<$head_branch)" |
25 | 23 | pr_number=$(curl -s -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "$pulls_uri" | |
26 | 24 | jq -r '.[] | .number') |
27 | 25 | echo "PR number: $pr_number" |
28 | 26 | echo "::set-output name=prnumber::$pr_number" |
29 | 27 |
|
| 28 | + - name: Create Deployment ID |
| 29 | + uses: altinukshini/[email protected] |
| 30 | + id: deployment |
| 31 | + with: |
| 32 | + token: "${{ secrets.ELEMENT_BOT_TOKEN }}" |
| 33 | + pr: true |
| 34 | + pr_id: ${{ steps.readctx.outputs.prnumber }} |
| 35 | + transient_environment: true |
| 36 | + environment: Netlify |
| 37 | + initial_status: in_progress |
| 38 | + ref: ${{ github.event.workflow_run.head_sha }} |
| 39 | + |
30 | 40 | # There's a 'download artifact' action but it hasn't been updated for the |
31 | 41 | # workflow_run action (https://github.com/actions/download-artifact/issues/60) |
32 | 42 | # so instead we get this mess: |
@@ -69,12 +79,25 @@ jobs: |
69 | 79 | NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
70 | 80 | timeout-minutes: 1 |
71 | 81 |
|
72 | | - - name: Edit PR Description |
73 | | - uses: Beakyn/gha-comment-pull-request@2167a7aee24f9e61ce76a23039f322e49a990409 |
74 | | - env: |
75 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + - name: Update deployment status (success) |
| 83 | + if: success() |
| 84 | + uses: altinukshini/[email protected] |
| 85 | + with: |
| 86 | + token: "${{ secrets.ELEMENT_BOT_TOKEN }}" |
| 87 | + environment_url: ${{ steps.netlify.outputs.deploy-url }} |
| 88 | + state: "success" |
| 89 | + deployment_id: ${{ steps.deployment.outputs.deployment_id }} |
| 90 | + pr: true |
| 91 | + pr_id: ${{ steps.readctx.outputs.prnumber }} |
| 92 | + description: | |
| 93 | + Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. |
| 94 | + Exercise caution. Use test accounts. |
| 95 | + - name: Update deployment status (failure) |
| 96 | + if: failure() |
| 97 | + uses: altinukshini/[email protected] |
76 | 98 | with: |
77 | | - pull-request-number: ${{ steps.readctx.outputs.prnumber }} |
78 | | - description-message: | |
79 | | - Preview: ${{ steps.netlify.outputs.deploy-url }} |
80 | | - ⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts. |
| 99 | + token: "${{ secrets.ELEMENT_BOT_TOKEN }}" |
| 100 | + state: "failure" |
| 101 | + deployment_id: ${{ steps.deployment.outputs.deployment_id }} |
| 102 | + pr: true |
| 103 | + pr_id: ${{ steps.readctx.outputs.prnumber }} |
0 commit comments