From 0e9e0129ab4ff7afece74bf1f817c77100f36ba0 Mon Sep 17 00:00:00 2001 From: Bernardo Simonassi Date: Sun, 26 Nov 2023 16:39:33 -0300 Subject: [PATCH] feat: improve deploy --- .github/workflows/deploy.yml | 99 +++++++++++---------- .github/workflows/prepare.yml | 92 +++++++++---------- .gitignore | 3 + .wrangler/state/v3/cache/default/db.sqlite | Bin 16384 -> 0 bytes apps/app/nuxt.config.ts | 10 +-- apps/www/components/atoms/Header.vue | 4 +- apps/www/nuxt.config.ts | 3 + apps/www/plugins/floating.ts | 10 --- wrangler.toml | 16 ---- 9 files changed, 108 insertions(+), 129 deletions(-) delete mode 100644 .wrangler/state/v3/cache/default/db.sqlite delete mode 100644 apps/www/plugins/floating.ts delete mode 100644 wrangler.toml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 76bbc53..76a583f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,47 +1,52 @@ -# name: Build and Deploy - -# on: -# workflow_call: -# inputs: -# APP_NAME: -# required: true -# type: string -# BUCKET: -# required: true -# type: string - -# jobs: -# build: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 - -# - uses: actions/setup-node@v3 -# with: -# node-version: 19 - -# - uses: pnpm/action-setup@v2 -# with: -# version: 8 - -# - name: Install Dependencies -# run: pnpm install - -# - name: Build -# run: pnpm generate --filter=${{ inputs.APP_NAME }} - -# - name: Configure AWS Credentials -# uses: aws-actions/configure-aws-credentials@v2 -# with: -# aws-region: sa-east-1 -# role-to-assume: arn:aws:iam::928571631969:role/gh-actions-menthorlabs-menthor - -# - name: Install AWS CLI -# id: install-aws-cli -# uses: unfor19/install-aws-cli-action@master - -# - name: Push to S3 -# run: aws s3 cp apps/${{ inputs.APP_NAME }}/dist ${{ inputs.BUCKET }} --recursive - -# - name: Invalidate CloudFront -# run: aws cloudfront create-invalidation --distribution-id E2B0K34D9WKXHA --paths "/*" \ No newline at end of file +name: Build and Deploy - Cloudflare Pages +on: + workflow_call: + inputs: + CLOUDFLARE_ENV: + required: false + type: string + default: ${{ contains(github.ref, 'main') && 'prod' || contains(github.ref, 'staging') && 'staging' || 'dev'}} + NODE_ENV: + required: false + type: string + default: ${{ contains(github.ref, 'main') && 'production' || contains(github.ref, 'staging') && 'staging' || 'development'}} + APP_NAME: + required: true + type: string + CLOUDFLARE_PROJECT_NAME: + required: true + type: string + +jobs: + setup-build-publish-deploy: + name: Publish to Cloudflare Pages + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + steps: + - uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 19 + + - name: Setup Yarn + uses: borales/actions-yarn@v4 + with: + cmd: install + + - name: Build Production Bundle + uses: borales/actions-yarn@v4 + with: + cmd: build:${{ inputs.NODE_ENV }} --filter=${{ inputs.APP_NAME }} + + - name: Publish to Cloudflare Pages + uses: cloudflare/pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }} + accountId: d8803c6a6253e9267bf1000ca69db18d + projectName: ${{ inputs.CLOUDFLARE_ENV }}-${{ inputs.CLOUDFLARE_PROJECT_NAME }} + directory: apps/${{ inputs.APP_NAME }}/dist + branch: main \ No newline at end of file diff --git a/.github/workflows/prepare.yml b/.github/workflows/prepare.yml index 5921413..52281fe 100644 --- a/.github/workflows/prepare.yml +++ b/.github/workflows/prepare.yml @@ -1,55 +1,51 @@ -# name: Menthor Apps Deployment +name: Apps Monorepo Deployment -# on: -# push: -# branches: -# - main +on: + push: + branches: + - dev + - staging + - main -# permissions: -# id-token: write -# contents: read +jobs: + changes: + name: Path filter + runs-on: ubuntu-latest -# jobs: -# changes: -# name: Path filter -# runs-on: ubuntu-latest - -# outputs: -# app: ${{ steps.filter.outputs.app }} -# www: ${{ steps.filter.outputs.www }} + outputs: + www: ${{ steps.filter.outputs.www }} + app: ${{ steps.filter.outputs.app }} -# steps: -# - name: Checkout -# uses: 'actions/checkout@v3' + steps: + - name: Checkout + uses: 'actions/checkout@v3' -# - uses: dorny/paths-filter@v2 -# id: filter -# with: -# base: ${{ github.ref }} -# filters: | -# app: -# - '.env.*' -# - 'apps/app/**' -# - 'packages/**' -# www: -# - '.env.*' -# - 'apps/www/**' -# - 'packages/**' + - uses: dorny/paths-filter@v2 + id: filter + with: + base: ${{ github.ref }} + filters: | + www: + - '.env.*' + - 'apps/www/**' + - 'packages/**' + app: + - '.env.*' + - 'apps/app/**' + - 'packages/**' -# app-deploy: -# needs: changes -# if: ${{ needs.changes.outputs.app == 'true' }} -# secrets: inherit -# uses: ./.github/workflows/deploy.yml -# with: -# APP_NAME: app -# BUCKET: s3://menthor.io-app/app + www-deploy: + needs: changes + if: ${{ needs.changes.outputs.www == 'true' }} + secrets: inherit + uses: ./.github/workflows/deploy-cloudrun.yaml + with: + APP_NAME: www -# www-deploy: -# needs: changes -# if: ${{ needs.changes.outputs.www == 'true' }} -# secrets: inherit -# uses: ./.github/workflows/deploy.yml -# with: -# APP_NAME: www -# BUCKET: s3://menthor.io \ No newline at end of file + app-deploy: + needs: changes + if: ${{ needs.changes.outputs.app == 'true' }} + secrets: inherit + uses: ./.github/workflows/deploy-cloudrun.yaml + with: + APP_NAME: app \ No newline at end of file diff --git a/.gitignore b/.gitignore index ddc2611..8bbe634 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ yarn-error.log* # vercel .vercel + +# wrangler +.wrangler diff --git a/.wrangler/state/v3/cache/default/db.sqlite b/.wrangler/state/v3/cache/default/db.sqlite deleted file mode 100644 index 3cc99955e4e45dc3208998f04a41b3537e59e952..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI#!Aiq07{Kwg8%_qgd2!dkE*pp-;@zr2hPBgLVLO$Mbx_?_-6G86UdcD`4SXDr zrki6$P&|)+APLFWCSQK-C3m-OqGLHoC!_mvYU+43$_NB;hbY1%oVhB$l5CWve2iaZpgMuP@mtr9-<4OYdtl~!!?b4-UdFt3AiaCn%>wJ~P3D2R zRDL!)ignbFbhLQB+&r { - + { - vueApp.use(FloatingVue); -}); diff --git a/wrangler.toml b/wrangler.toml deleted file mode 100644 index 44b0369..0000000 --- a/wrangler.toml +++ /dev/null @@ -1,16 +0,0 @@ -name = "menthor-app" -main = "./apps/app/.output/server/index.mjs" -workers_dev = true -compatibility_date = "2022-09-10" -account_id = "d8803c6a6253e9267bf1000ca69db18d" - -rules = [ - { type = "ESModule", globs = ["**/*.js", "**/*.mjs"]}, -] - -[site] -bucket = "apps/app/.output/public" - -[env.dev] -bucket = "apps/app/.output/public" -route = "*dev.menthor.io/app*" \ No newline at end of file