diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c640c21..7e15e13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,9 @@ on: branches: ['main'] pull_request: +permissions: + pull-requests: write + env: NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} @@ -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: | + ## Preparing to Deploy Preview... + + | Name | Link | + | ---- | ---- | + | **Latest commit** | ${{ github.sha }} | + - name: Checkout uses: actions/checkout@v4 with: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 992dc98..58d2c6e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 }} @@ -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: | + ## 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: @@ -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: | + ## 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 }} |