Skip to content

Commit

Permalink
ci: add pr comment for cloudflare pages preview (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
nix6839 committed Sep 15, 2023
1 parent 4ea4b42 commit 21aa278
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: ['main']
pull_request:

permissions:
pull-requests: write

env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

Expand All @@ -17,6 +20,18 @@ jobs:
node-version: [18, 20]

steps:
- name: Comment preparing to deploy
if: ${{ github.event_name != 'push' }}
uses: mshick/add-pr-comment@v2
with:
message-id: cloudflare-pages-preview-deployment
message: |
## <span aria-hidden="true">🚧</span> Preparing to Deploy Preview...
| Name | Link |
| ---- | ---- |
| **Latest commit** | ${{ github.sha }} |
- name: Checkout
uses: actions/checkout@v4
with:
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ concurrency:
group: 'pages'
cancel-in-progress: true

permissions:
pull-requests: write

env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

Expand All @@ -21,6 +24,19 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}

steps:
- name: Comment start deploying preview
if: ${{ github.event.workflow_run.event != 'push' }}
uses: mshick/add-pr-comment@v2
with:
message-id: cloudflare-pages-preview-deployment
message: |
## <span aria-hidden="true">📤</span> Start Deploying preview...
| Name | Link |
| ---- | ---- |
| **Latest commit** | ${{ github.sha }} |
| **Latest deploy log** | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
- name: Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -49,8 +65,24 @@ jobs:

- name: Deploy
uses: cloudflare/pages-action@v1
id: deploy-cloudflare-pages
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: portfolio
directory: ./apps/portfolio/dist/

- name: Comment preview deployed successful
if: ${{ github.event.workflow_run.event != 'push' }}
uses: mshick/add-pr-comment@v2
with:
message-id: cloudflare-pages-preview-deployment
message: |
## <span aria-hidden="true">✅</span> Preview Deployed Successfully!
| Name | Link |
| ---- | ---- |
| **Latest commit** | ${{ github.sha }} |
| **Latest deploy log** | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| **Preview URL (Latest)** | ${{ steps.deploy-cloudflare-pages.outputs.url }} |
| **Preview URL (Branch)** | ${{ steps.deploy-cloudflare-pages.outputs.alias }} |

0 comments on commit 21aa278

Please sign in to comment.