From 755577a411a82a49acf658f6e219e393d7d40a30 Mon Sep 17 00:00:00 2001 From: "Bernard \"BeroBurny\" Stojanovic" Date: Tue, 10 Dec 2024 15:14:37 +0700 Subject: [PATCH 1/9] chore: refactor cf pages ci/cd from `gopher-*`to `sprinter-*` --- .github/workflows/cd.yml | 15 +++++++++++---- .github/workflows/ci.yml | 28 ++++++++++++++++------------ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 4222c40..c2fd108 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -49,11 +49,18 @@ jobs: - name: Publish Docs to Cloudflare Pages if: ${{ steps.release.outputs.releases_created }} - uses: cloudflare/pages-action@v1 + uses: cloudflare/wrangler-action@v3 with: + gitHubToken: ${{ secrets.GITHUB_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb - projectName: gopher-docs-preview - directory: ./docs/build + command: pages deploy ./docs/build --project-name=sprinter-docs + + - name: Publish POC to Cloudflare Pages + if: ${{ steps.release.outputs.releases_created }} + uses: cloudflare/wrangler-action@v3 + with: gitHubToken: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.head_ref || github.ref_name }} \ No newline at end of file + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: 2238a825c5aca59233eab1f221f7aefb + command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 399e3b3..0318b92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,21 +29,25 @@ jobs: run: 'yarn run test:unit' - name: "Integrations Tests" run: 'yarn run test:integrations' - - name: Publish POC to Cloudflare Pages - uses: cloudflare/pages-action@v1 + - name: Set branch name for Cloudflare Pages + id: cf-branch + run: | + if [[ "${{ github.ref_name }}" == "master" ]]; then + echo "CF_BRANCH_NAME=preview" >> $GITHUB_ENV + else + echo "CF_BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV + fi + - name: Publish Docs to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 with: + gitHubToken: ${{ secrets.GITHUB_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb - projectName: gopher-poc - directory: ./web/.svelte-kit/cloudflare - gitHubToken: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.head_ref || github.ref_name }} - - name: Publish Preview Docs to Cloudflare Pages - uses: cloudflare/pages-action@v1 + command: pages deploy ./docs/build --project-name=sprinter-docs --branch=${{ env.CF_BRANCH_NAME }} + - name: Publish POC to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 with: + gitHubToken: ${{ secrets.GITHUB_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb - projectName: gopher-docs-preview - directory: ./docs/build - gitHubToken: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.head_ref || github.ref_name }} \ No newline at end of file + command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc --branch=${{ env.CF_BRANCH_NAME }} From 2767be7e36500fdc56bca34e75c5bd860e54c5fb Mon Sep 17 00:00:00 2001 From: "Bernard \"BeroBurny\" Stojanovic" Date: Tue, 10 Dec 2024 17:33:22 +0700 Subject: [PATCH 2/9] let's see if works --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0318b92..12d5f49 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,8 @@ jobs: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb command: pages deploy ./docs/build --project-name=sprinter-docs --branch=${{ env.CF_BRANCH_NAME }} + environment: + name: sprinter-docs - name: Publish POC to Cloudflare Pages uses: cloudflare/wrangler-action@v3 with: @@ -51,3 +53,5 @@ jobs: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc --branch=${{ env.CF_BRANCH_NAME }} + environment: + name: sprinter-poc From 00b050ab4436bae37834d2171c53c656e557f591 Mon Sep 17 00:00:00 2001 From: "Bernard \"BeroBurny\" Stojanovic" Date: Tue, 10 Dec 2024 17:55:15 +0700 Subject: [PATCH 3/9] hmmm --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12d5f49..dbbcbfa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,15 +43,13 @@ jobs: gitHubToken: ${{ secrets.GITHUB_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb + environment: sprinter-docs command: pages deploy ./docs/build --project-name=sprinter-docs --branch=${{ env.CF_BRANCH_NAME }} - environment: - name: sprinter-docs - name: Publish POC to Cloudflare Pages uses: cloudflare/wrangler-action@v3 with: gitHubToken: ${{ secrets.GITHUB_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb + environment: sprinter-poc command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc --branch=${{ env.CF_BRANCH_NAME }} - environment: - name: sprinter-poc From faf56122220c28eb9586da9db2e509aa0ecacca6 Mon Sep 17 00:00:00 2001 From: "Bernard \"BeroBurny\" Stojanovic" Date: Tue, 10 Dec 2024 18:21:20 +0700 Subject: [PATCH 4/9] dis? --- .github/workflows/ci.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbbcbfa..c5174d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,6 @@ jobs: gitHubToken: ${{ secrets.GITHUB_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb - environment: sprinter-docs command: pages deploy ./docs/build --project-name=sprinter-docs --branch=${{ env.CF_BRANCH_NAME }} - name: Publish POC to Cloudflare Pages uses: cloudflare/wrangler-action@v3 @@ -51,5 +50,21 @@ jobs: gitHubToken: ${{ secrets.GITHUB_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb - environment: sprinter-poc command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc --branch=${{ env.CF_BRANCH_NAME }} + - name: Create deployment for docs + run: | + gh api repos/${{ github.repository }}/deployments \ + -X POST \ + -F ref="${{ github.ref }}" \ + -F environment="gopher-docs-preview" \ + -F description="Deploying documentation preview" \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" + + - name: Create deployment for POC + run: | + gh api repos/${{ github.repository }}/deployments \ + -X POST \ + -F ref="${{ github.ref }}" \ + -F environment="gopher-poc-preview" \ + -F description="Deploying POC preview" \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" From e63e38c87e839dae1e66a53faeaaeac84b58c782 Mon Sep 17 00:00:00 2001 From: "Bernard \"BeroBurny\" Stojanovic" Date: Tue, 10 Dec 2024 18:27:14 +0700 Subject: [PATCH 5/9] dis and env --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5174d7..dfd5a74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,6 +52,8 @@ jobs: accountId: 2238a825c5aca59233eab1f221f7aefb command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc --branch=${{ env.CF_BRANCH_NAME }} - name: Create deployment for docs + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh api repos/${{ github.repository }}/deployments \ -X POST \ @@ -61,6 +63,8 @@ jobs: -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" - name: Create deployment for POC + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh api repos/${{ github.repository }}/deployments \ -X POST \ From 4d51114ecdcae2977c9749d0ca4f7c6894955cb2 Mon Sep 17 00:00:00 2001 From: "Bernard \"BeroBurny\" Stojanovic" Date: Tue, 10 Dec 2024 18:47:33 +0700 Subject: [PATCH 6/9] last one --- .github/workflows/ci.yml | 67 ++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dfd5a74..2034d31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,38 +37,65 @@ jobs: else echo "CF_BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV fi + + # Deploy Docs + - name: Create GitHub Deployment for Docs + id: docs-deployment + uses: octokit/request-action@v2 + with: + route: POST /repos/${{ github.repository }}/deployments + environment: gopher-docs-preview + ref: ${{ github.ref }} + description: Deploying Docs preview + auto_merge: false + payload: '{"project": "docs"}' + token: ${{ secrets.GITHUB_TOKEN }} + - name: Publish Docs to Cloudflare Pages + id: docs-publish uses: cloudflare/wrangler-action@v3 with: gitHubToken: ${{ secrets.GITHUB_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb command: pages deploy ./docs/build --project-name=sprinter-docs --branch=${{ env.CF_BRANCH_NAME }} + + - name: Update Docs Deployment Status + uses: octokit/request-action@v2 + with: + route: POST /repos/${{ github.repository }}/deployments/${{ steps.docs-deployment.outputs.deployment_id }}/statuses + state: success + environment_url: ${{ steps.docs-publish.outputs.deployment-url }} + description: Docs deployed successfully + token: ${{ secrets.GITHUB_TOKEN }} + + # Deploy POC + - name: Create GitHub Deployment for POC + id: poc-deployment + uses: octokit/request-action@v2 + with: + route: POST /repos/${{ github.repository }}/deployments + environment: gopher-poc-preview + ref: ${{ github.ref }} + description: Deploying POC preview + auto_merge: false + payload: '{"project": "poc"}' + token: ${{ secrets.GITHUB_TOKEN }} + - name: Publish POC to Cloudflare Pages + id: poc-publish uses: cloudflare/wrangler-action@v3 with: gitHubToken: ${{ secrets.GITHUB_TOKEN }} apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc --branch=${{ env.CF_BRANCH_NAME }} - - name: Create deployment for docs - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh api repos/${{ github.repository }}/deployments \ - -X POST \ - -F ref="${{ github.ref }}" \ - -F environment="gopher-docs-preview" \ - -F description="Deploying documentation preview" \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" - - name: Create deployment for POC - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh api repos/${{ github.repository }}/deployments \ - -X POST \ - -F ref="${{ github.ref }}" \ - -F environment="gopher-poc-preview" \ - -F description="Deploying POC preview" \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" + - name: Update POC Deployment Status + uses: octokit/request-action@v2 + with: + route: POST /repos/${{ github.repository }}/deployments/${{ steps.poc-deployment.outputs.deployment_id }}/statuses + state: success + environment_url: ${{ steps.poc-publish.outputs.deployment-url }} + description: POC deployed successfully + token: ${{ secrets.GITHUB_TOKEN }} From 33f108a0b2312c3cd3ef9e70a44d9ff540e5709c Mon Sep 17 00:00:00 2001 From: "Bernard \"BeroBurny\" Stojanovic" Date: Tue, 10 Dec 2024 18:50:09 +0700 Subject: [PATCH 7/9] diff octokit version? --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2034d31..c1ee408 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: # Deploy Docs - name: Create GitHub Deployment for Docs id: docs-deployment - uses: octokit/request-action@v2 + uses: octokit/request-action@v2.x with: route: POST /repos/${{ github.repository }}/deployments environment: gopher-docs-preview @@ -61,7 +61,7 @@ jobs: command: pages deploy ./docs/build --project-name=sprinter-docs --branch=${{ env.CF_BRANCH_NAME }} - name: Update Docs Deployment Status - uses: octokit/request-action@v2 + uses: octokit/request-action@v2.x with: route: POST /repos/${{ github.repository }}/deployments/${{ steps.docs-deployment.outputs.deployment_id }}/statuses state: success @@ -72,7 +72,7 @@ jobs: # Deploy POC - name: Create GitHub Deployment for POC id: poc-deployment - uses: octokit/request-action@v2 + uses: octokit/request-action@v2.x with: route: POST /repos/${{ github.repository }}/deployments environment: gopher-poc-preview @@ -92,7 +92,7 @@ jobs: command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc --branch=${{ env.CF_BRANCH_NAME }} - name: Update POC Deployment Status - uses: octokit/request-action@v2 + uses: octokit/request-action@v2.x with: route: POST /repos/${{ github.repository }}/deployments/${{ steps.poc-deployment.outputs.deployment_id }}/statuses state: success From a6929a82b40baaeac05447b3f4a542f624142eb0 Mon Sep 17 00:00:00 2001 From: "Bernard \"BeroBurny\" Stojanovic" Date: Tue, 10 Dec 2024 18:58:25 +0700 Subject: [PATCH 8/9] manual --- .github/workflows/ci.yml | 66 +++++++++++++--------------------------- 1 file changed, 21 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1ee408..08840b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,20 +37,6 @@ jobs: else echo "CF_BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV fi - - # Deploy Docs - - name: Create GitHub Deployment for Docs - id: docs-deployment - uses: octokit/request-action@v2.x - with: - route: POST /repos/${{ github.repository }}/deployments - environment: gopher-docs-preview - ref: ${{ github.ref }} - description: Deploying Docs preview - auto_merge: false - payload: '{"project": "docs"}' - token: ${{ secrets.GITHUB_TOKEN }} - - name: Publish Docs to Cloudflare Pages id: docs-publish uses: cloudflare/wrangler-action@v3 @@ -59,29 +45,6 @@ jobs: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb command: pages deploy ./docs/build --project-name=sprinter-docs --branch=${{ env.CF_BRANCH_NAME }} - - - name: Update Docs Deployment Status - uses: octokit/request-action@v2.x - with: - route: POST /repos/${{ github.repository }}/deployments/${{ steps.docs-deployment.outputs.deployment_id }}/statuses - state: success - environment_url: ${{ steps.docs-publish.outputs.deployment-url }} - description: Docs deployed successfully - token: ${{ secrets.GITHUB_TOKEN }} - - # Deploy POC - - name: Create GitHub Deployment for POC - id: poc-deployment - uses: octokit/request-action@v2.x - with: - route: POST /repos/${{ github.repository }}/deployments - environment: gopher-poc-preview - ref: ${{ github.ref }} - description: Deploying POC preview - auto_merge: false - payload: '{"project": "poc"}' - token: ${{ secrets.GITHUB_TOKEN }} - - name: Publish POC to Cloudflare Pages id: poc-publish uses: cloudflare/wrangler-action@v3 @@ -90,12 +53,25 @@ jobs: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: 2238a825c5aca59233eab1f221f7aefb command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc --branch=${{ env.CF_BRANCH_NAME }} - - - name: Update POC Deployment Status - uses: octokit/request-action@v2.x + - name: Generate Deployment Summary + run: | + echo "# 🚀 Deployment Summary" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| **Project** | **Preview URL** |" >> $GITHUB_STEP_SUMMARY + echo "| ----------------------- | ---------------- |" >> $GITHUB_STEP_SUMMARY + echo "| **Docs** | [View Docs](${{ steps.docs-publish.outputs.deployment-url }}) |" >> $GITHUB_STEP_SUMMARY + echo "| **POC** | [View POC](${{ steps.poc-publish.outputs.deployment-url }}) |" >> $GITHUB_STEP_SUMMARY + - name: Notify About Deployment + if: ${{ github.actor != 'dependabot[bot]' }} + uses: actions/github-script@v7 with: - route: POST /repos/${{ github.repository }}/deployments/${{ steps.poc-deployment.outputs.deployment_id }}/statuses - state: success - environment_url: ${{ steps.poc-publish.outputs.deployment-url }} - description: POC deployed successfully - token: ${{ secrets.GITHUB_TOKEN }} + script: | + const docsUrl = `**Docs:** [View Deployment](${{ steps.docs-publish.outputs.deployment-url }})`; + const pocUrl = `**POC:** [View Deployment](${{ steps.poc-publish.outputs.deployment-url }})`; + const message = `🚀 **Deployment Completed**\n\n${docsUrl}\n${pocUrl}`; + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: message, + }); From e1e94083cd749d35ba00e35100858f43154c195f Mon Sep 17 00:00:00 2001 From: "Bernard \"BeroBurny\" Stojanovic" Date: Tue, 10 Dec 2024 19:03:29 +0700 Subject: [PATCH 9/9] more pretty? --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08840b6..ce6da1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,15 +59,15 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY echo "| **Project** | **Preview URL** |" >> $GITHUB_STEP_SUMMARY echo "| ----------------------- | ---------------- |" >> $GITHUB_STEP_SUMMARY - echo "| **Docs** | [View Docs](${{ steps.docs-publish.outputs.deployment-url }}) |" >> $GITHUB_STEP_SUMMARY - echo "| **POC** | [View POC](${{ steps.poc-publish.outputs.deployment-url }}) |" >> $GITHUB_STEP_SUMMARY + echo "| **Docs** | [View Docs -> ${{ steps.docs-publish.outputs.deployment-url }}](${{ steps.docs-publish.outputs.deployment-url }}) |" >> $GITHUB_STEP_SUMMARY + echo "| **POC** | [View POC -> ${{ steps.poc-publish.outputs.deployment-url }}](${{ steps.poc-publish.outputs.deployment-url }}) |" >> $GITHUB_STEP_SUMMARY - name: Notify About Deployment if: ${{ github.actor != 'dependabot[bot]' }} uses: actions/github-script@v7 with: script: | - const docsUrl = `**Docs:** [View Deployment](${{ steps.docs-publish.outputs.deployment-url }})`; - const pocUrl = `**POC:** [View Deployment](${{ steps.poc-publish.outputs.deployment-url }})`; + const docsUrl = `**Docs:** [View Deployment -> ${{ steps.docs-publish.outputs.deployment-url }}](${{ steps.docs-publish.outputs.deployment-url }})`; + const pocUrl = `**POC:** [View Deployment -> ${{ steps.poc-publish.outputs.deployment-url }}](${{ steps.poc-publish.outputs.deployment-url }})`; const message = `🚀 **Deployment Completed**\n\n${docsUrl}\n${pocUrl}`; await github.rest.issues.createComment({ issue_number: context.issue.number,