Skip to content

Commit

Permalink
feat: improve deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
BernardoSM committed Nov 26, 2023
1 parent f904a83 commit 0e9e012
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 129 deletions.
99 changes: 52 additions & 47 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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 "/*"
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
92 changes: 44 additions & 48 deletions .github/workflows/prepare.yml
Original file line number Diff line number Diff line change
@@ -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
app-deploy:
needs: changes
if: ${{ needs.changes.outputs.app == 'true' }}
secrets: inherit
uses: ./.github/workflows/deploy-cloudrun.yaml
with:
APP_NAME: app
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ yarn-error.log*

# vercel
.vercel

# wrangler
.wrangler
Binary file removed .wrangler/state/v3/cache/default/db.sqlite
Binary file not shown.
10 changes: 4 additions & 6 deletions apps/app/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -40,6 +35,9 @@ export default defineNuxtConfig({
buildAssetsDir: "_nuxt",
},
},
// output: {
// publicDir: "../www/dist/app",
// },
},
app: {
baseURL: process.env.NODE_ENV === "development" ? "/" : baseURL,
Expand Down
4 changes: 2 additions & 2 deletions apps/www/components/atoms/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ onMounted(() => {

<!-- <AtomsHeaderLink title="Documentação" /> -->

<VDropdown :distance="6" placement="bottom">
<!-- <VDropdown :distance="6" placement="bottom">
<AtomsHeaderLink title="Comunidade" chevron />
<template #popper="{ hide }">
<div @click="hide()" class="py-2">
Expand Down Expand Up @@ -118,7 +118,7 @@ onMounted(() => {
</nuxt-link>
</div>
</template>
</VDropdown>
</VDropdown> -->
</div>

<nuxt-link
Expand Down
3 changes: 3 additions & 0 deletions apps/www/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default defineNuxtConfig({
appUrl: process.env.NUXT_PUBLIC_APP_URL || "https://menthor.io/app",
},
},
nitro: {
preset: "cloudflare_pages_static",
},
imports: {
dirs: ["composables", "../../packages/composables"],
},
Expand Down
10 changes: 0 additions & 10 deletions apps/www/plugins/floating.ts

This file was deleted.

16 changes: 0 additions & 16 deletions wrangler.toml

This file was deleted.

0 comments on commit 0e9e012

Please sign in to comment.