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 3cc9995..0000000 Binary files a/.wrangler/state/v3/cache/default/db.sqlite and /dev/null differ diff --git a/apps/app/nuxt.config.ts b/apps/app/nuxt.config.ts index f78bcab..64ce643 100644 --- a/apps/app/nuxt.config.ts +++ b/apps/app/nuxt.config.ts @@ -23,13 +23,8 @@ export default defineNuxtConfig({ appUrl: process.env.NUXT_PUBLIC_APP_URL, }, }, - routeRules: { - "/sign-in": { ssr: false }, - "/": { prerender: true }, - "/profile": { ssr: true }, - }, nitro: { - preset: "cloudflare", + preset: "cloudflare_pages", baseURL: process.env.NODE_ENV === "development" ? "/" : baseURL, prerender: { crawlLinks: true, @@ -40,6 +35,9 @@ export default defineNuxtConfig({ buildAssetsDir: "_nuxt", }, }, + // output: { + // publicDir: "../www/dist/app", + // }, }, app: { baseURL: process.env.NODE_ENV === "development" ? "/" : baseURL, diff --git a/apps/www/components/atoms/Header.vue b/apps/www/components/atoms/Header.vue index 8d7a297..9de0b2c 100644 --- a/apps/www/components/atoms/Header.vue +++ b/apps/www/components/atoms/Header.vue @@ -79,7 +79,7 @@ onMounted(() => { - + { - 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