From cb93021a86e13816f8fe860d56a8c24f405ec391 Mon Sep 17 00:00:00 2001 From: "Vipul Gupta (@vipulgupta2048)" Date: Thu, 11 Jul 2024 00:39:41 +0530 Subject: [PATCH] patch: Add Cloudflare Pages link as PR comment Signed-off-by: Vipul Gupta (@vipulgupta2048) --- .github/workflows/flowzone.yml | 19 +++++++++++++++++-- flowzone.yml | 21 +++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/flowzone.yml b/.github/workflows/flowzone.yml index 7c5c7c66a..932fb1c67 100644 --- a/.github/workflows/flowzone.yml +++ b/.github/workflows/flowzone.yml @@ -3494,13 +3494,28 @@ jobs: run: | echo "CF_BRANCH=${{ github.event.repository.default_branch }}" >> "${GITHUB_ENV}" - name: Deploy to Cloudflare Pages + id: deploy_cf_pages uses: cloudflare/wrangler-action@f84a562284fc78278ff9052435d9526f9c718361 with: apiToken: ${{ secrets.CF_API_TOKEN }} accountId: ${{ secrets.CF_ACCOUNT_ID }} wranglerVersion: 3.5.1 - command: --version - postCommands: npx wrangler pages deploy --branch ${{ env.CF_BRANCH }} --project-name=${{ inputs.cloudflare_website }} build/ | tee -a $GITHUB_STEP_SUMMARY + command: pages deploy --branch ${{ env.CF_BRANCH }} --project-name=${{ inputs.cloudflare_website }} build/ + - name: Find Cloudflare Pages link comment + uses: peter-evans/find-comment@v3.1.0 + id: find_cf_comment + with: + issue-number: ${{ github.event.pull_request.number }} + body-includes: Website deployed to CF Pages, 👀 preview link + - name: Create or update Cloudflare Pages link comment if deployment link present + uses: peter-evans/create-or-update-comment@v4.0.0 + if: steps.deploy_cf_pages.outputs.deployment-url != '' + with: + comment-id: ${{ steps.find_cf_comment.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + edit-mode: replace + body: | + Website deployed to CF Pages, 👀 preview link ${{ steps.deploy_cf_pages.outputs.deployment-url }} github_clean: name: Clean GitHub release runs-on: ${{ fromJSON(inputs.runs_on) }} diff --git a/flowzone.yml b/flowzone.yml index 07e03cf40..2a1f19b55 100644 --- a/flowzone.yml +++ b/flowzone.yml @@ -3286,13 +3286,30 @@ jobs: echo "CF_BRANCH=${{ github.event.repository.default_branch }}" >> "${GITHUB_ENV}" - name: Deploy to Cloudflare Pages + id: deploy_cf_pages uses: cloudflare/wrangler-action@f84a562284fc78278ff9052435d9526f9c718361 # v3.7.0 with: apiToken: ${{ secrets.CF_API_TOKEN }} accountId: ${{ secrets.CF_ACCOUNT_ID }} wranglerVersion: "3.5.1" # latest - https://www.npmjs.com/package/wrangler - command: --version - postCommands: npx wrangler pages deploy --branch ${{ env.CF_BRANCH }} --project-name=${{ inputs.cloudflare_website }} build/ | tee -a $GITHUB_STEP_SUMMARY + command: pages deploy --branch ${{ env.CF_BRANCH }} --project-name=${{ inputs.cloudflare_website }} build/ + + - name: Find Cloudflare Pages link comment + uses: peter-evans/find-comment@v3.1.0 + id: find_cf_comment + with: + issue-number: ${{ github.event.pull_request.number }} + body-includes: Website deployed to CF Pages, 👀 preview link + + - name: Create or update Cloudflare Pages link comment if deployment link present + uses: peter-evans/create-or-update-comment@v4.0.0 + if: steps.deploy_cf_pages.outputs.deployment-url != '' + with: + comment-id: ${{ steps.find_cf_comment.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + edit-mode: replace + body: | + Website deployed to CF Pages, 👀 preview link ${{ steps.deploy_cf_pages.outputs.deployment-url }} ################################################### # GitHub