Skip to content

Commit 3bb694b

Browse files
authored
chore(ci): support to comment with deployed url (#5)
1 parent a218ccc commit 3bb694b

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

.github/workflows/preview-docs-deployment.yaml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,31 @@ on:
88
jobs:
99
build:
1010
name: Build
11+
permissions:
12+
pull-requests: write
1113
runs-on: ubuntu-22.04
1214
steps:
15+
- name: Find Comment
16+
uses: peter-evans/find-comment@v2
17+
id: fc
18+
with:
19+
issue-number: ${{ github.event.pull_request.number }}
20+
comment-author: 'github-actions[bot]'
21+
body-includes: to Netlify
22+
23+
- name: Create or update comment
24+
uses: peter-evans/create-or-update-comment@v3
25+
with:
26+
comment-id: ${{ steps.fc.outputs.comment-id }}
27+
issue-number: ${{ github.event.pull_request.number }}
28+
body: |
29+
## 🚧 Deploying to Netlify
30+
31+
| Status | URL |
32+
|-------------|--------------------------------------|
33+
| Pending | `URL will be revealed once deployed` |
34+
edit-mode: replace
35+
1336
- name: Checkout
1437
uses: actions/checkout@v3
1538
with:
@@ -51,10 +74,25 @@ jobs:
5174
run: pnpm install -g netlify-cli
5275

5376
- name: Push to Netlify
77+
id: netlify
5478
timeout-minutes: 10
5579
working-directory: docs/
56-
run: netlify deploy --dir .vitepress/dist
80+
run: |
81+
echo "NETLIFY_URL=$(netlify deploy --dir .vitepress/dist --json | jq -r .deploy_url)" >> $GITHUB_ENV
82+
cat $GITHUB_ENV
5783
env:
5884
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
5985
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
6086

87+
- name: Create or update comment
88+
uses: peter-evans/create-or-update-comment@v3
89+
with:
90+
comment-id: ${{ steps.fc.outputs.comment-id }}
91+
issue-number: ${{ github.event.pull_request.number }}
92+
body: |
93+
## ✅ Deployed to Netlify
94+
95+
| Status | URL |
96+
|-------------|-----------------------------------------------------|
97+
| Success | ${{ env.NETLIFY_URL }} |
98+
edit-mode: replace

0 commit comments

Comments
 (0)