From 7ff0ab738b36afe9f6bffeaea47f763535db47cb Mon Sep 17 00:00:00 2001 From: rndquu Date: Mon, 18 Mar 2024 14:20:06 +0300 Subject: [PATCH 1/2] ci: add reusable cloudflare deploy --- .github/workflows/build.yml | 28 ++++++++-------------------- .github/workflows/deploy.yml | 12 ++++++++++++ .github/workflows/init.yml | 15 --------------- 3 files changed, 20 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/init.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e18a40e..28d7188 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,9 @@ -name: Build & Deploy +name: Build on: - workflow_run: - workflows: ["Init"] - types: - - completed + push: + pull_request: + workflow_dispatch: permissions: contents: read @@ -16,8 +15,6 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v4 - # with: - # submodules: "recursive" # Ensures submodules are checked out - name: Set up Node.js uses: actions/setup-node@v4 @@ -28,18 +25,9 @@ jobs: run: | yarn yarn build - # env: # Set environment variables for the build - # SUPABASE_URL: "https://wfzpewmlyiozupulbuur.supabase.co" - # SUPABASE_ANON_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndmenBld21seWlvenVwdWxidXVyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTU2NzQzMzksImV4cCI6MjAxMTI1MDMzOX0.SKIL3Q0NOBaMehH0ekFspwgcu3afp3Dl9EDzPqs1nKs" - - name: Deploy to Cloudflare - uses: ubiquity/cloudflare-deploy-action@main + - name: Upload build artifact + uses: actions/upload-artifact@v4 with: - repository: ${{ github.repository }} - production_branch: ${{ github.event.repository.default_branch }} - output_directory: "static" - current_branch: ${{ github.ref_name }} - pull_request_number: ${{ github.event.pull_request.number }} - cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }} - commit_sha: ${{ github.event.pull_request.head.sha }} + name: static + path: static diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..b669e28 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,12 @@ +name: Deploy to Cloudflare Pages + +on: + workflow_run: + workflows: ["Build"] + types: + - completed + +jobs: + deploy-to-cloudflare: + uses: ubiquity/.github/.github/workflows/deploy.yml@main + secrets: inherit diff --git a/.github/workflows/init.yml b/.github/workflows/init.yml deleted file mode 100644 index 195cd29..0000000 --- a/.github/workflows/init.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Initializes the "build and deploy" workflow to have access to github secrets in that workflow -name: Init - -on: - push: - pull_request: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-22.04 - steps: - - name: Init - run: | - echo "Initialized" From 90671efbc95e64927689d5c8087eac1bc4a4e633 Mon Sep 17 00:00:00 2001 From: rndquu Date: Mon, 18 Mar 2024 19:19:10 +0300 Subject: [PATCH 2/2] ci: use single action --- .github/workflows/deploy.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b669e28..28d7c03 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,5 +8,18 @@ on: jobs: deploy-to-cloudflare: - uses: ubiquity/.github/.github/workflows/deploy.yml@main - secrets: inherit + name: Automatic Cloudflare Deploy + runs-on: ubuntu-22.04 + steps: + - name: Deploy to Cloudflare + if: ${{ github.event.workflow_run.conclusion == 'success' }} + uses: ubiquity/cloudflare-deploy-action@main + with: + repository: ${{ github.repository }} + production_branch: ${{ github.event.repository.default_branch }} + output_directory: "static" + current_branch: ${{ github.event.workflow_run.head_branch }} + cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }} + commit_sha: ${{ github.event.workflow_run.head_sha }} + workflow_run_id: ${{ github.event.workflow_run.id }}