Preview PR ⚡ #256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Preview PR ⚡ | |
on: | |
workflow_run: | |
workflows: ["CICD 🚀"] | |
types: | |
- completed | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
if: > | |
github.event.workflow_run.event == 'pull_request' && | |
github.event.workflow_run.conclusion == 'success' | |
permissions: | |
pull-requests: write | |
steps: | |
- uses: dawidd6/action-download-artifact@v2 | |
with: | |
run_id: ${{ github.event.workflow_run.id }} | |
name: pr | |
- run: echo "PR_NUM=$(cat pr.txt | awk '{print 0 + $1; exit;}')" >> $GITHUB_ENV | |
- uses: dawidd6/action-download-artifact@v2 | |
with: | |
run_id: ${{ github.event.workflow_run.id }} | |
name: build-web | |
path: dist_web | |
- uses: dawidd6/action-download-artifact@v2 | |
with: | |
run_id: ${{ github.event.workflow_run.id }} | |
name: demo | |
path: dist_web | |
- name: Publish | |
uses: cloudflare/pages-action@1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: chat-analytics | |
directory: dist_web | |
branch: pr-${{ env.PR_NUM }} | |
# add comment status in PR | |
- name: Find Comment | |
id: fc | |
uses: peter-evans/find-comment@v2 | |
with: | |
issue-number: ${{ env.PR_NUM }} | |
comment-author: 'github-actions[bot]' | |
body-includes: Preview for this PR | |
- name: Create or update comment | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ env.PR_NUM }} | |
body: | | |
⚡ Preview for this PR: https://pr-${{ env.PR_NUM }}.chat-analytics.pages.dev | |
📊 [Demo](https://pr-${{ env.PR_NUM }}.chat-analytics.pages.dev/demo) | |
edit-mode: replace |