diff --git a/.github/workflows/preview-docs-deployment.yaml b/.github/workflows/preview-docs-deployment.yaml index 81eedd16..71a77a69 100644 --- a/.github/workflows/preview-docs-deployment.yaml +++ b/.github/workflows/preview-docs-deployment.yaml @@ -8,8 +8,31 @@ on: jobs: build: name: Build + permissions: + pull-requests: write runs-on: ubuntu-22.04 steps: + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: to Netlify + + - name: Create or update comment + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + ## 🚧 Deploying to Netlify + + | Status | URL | + |-------------|--------------------------------------| + | Pending | `URL will be revealed once deployed` | + edit-mode: replace + - name: Checkout uses: actions/checkout@v3 with: @@ -51,10 +74,25 @@ jobs: run: pnpm install -g netlify-cli - name: Push to Netlify + id: netlify timeout-minutes: 10 working-directory: docs/ - run: netlify deploy --dir .vitepress/dist + run: | + echo "NETLIFY_URL=$(netlify deploy --dir .vitepress/dist --json | jq -r .deploy_url)" >> $GITHUB_ENV + cat $GITHUB_ENV env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + - name: Create or update comment + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + ## ✅ Deployed to Netlify + + | Status | URL | + |-------------|-----------------------------------------------------| + | Success | ${{ env.NETLIFY_URL }} | + edit-mode: replace