Skip to content

Commit

Permalink
chore: ci/cd for multiple apps
Browse files Browse the repository at this point in the history
  • Loading branch information
BernardoSM committed Aug 13, 2023
1 parent 556a62d commit e67af28
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 8 deletions.
29 changes: 21 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Deploy
name: Build and Deploy

on:
push:
branches:
- main
workflow_call:
inputs:
APP_NAME:
required: true
type: string
BUCKET:
required: true
type: string

permissions:
id-token: write
Expand All @@ -14,25 +19,33 @@ jobs:
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

- name: Install Dependencies
run: pnpm install

- name: Build
run: pnpm generate --filter=app
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

- name: Install AWS CLI
id: install-aws-cli
uses: unfor19/install-aws-cli-action@master

- name: Push to S3
run: aws s3 cp apps/app/dist s3://menthor.io-app/app --recursive
run: aws s3 cp apps/${{ inputs.APP_NAME }}/dist ${{ inputs.BUCKET }} --recursive

- name: Invalidate CloudFront
run: aws cloudfront create-invalidation --distribution-id E2B0K34D9WKXHA --paths "/*"
51 changes: 51 additions & 0 deletions .github/workflows/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Menthor Apps Deployment

on:
push:
branches:
- main

jobs:
changes:
name: Path filter
runs-on: ubuntu-latest

outputs:
app: ${{ steps.filter.outputs.app }}
www: ${{ steps.filter.outputs.www }}

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/**'
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.yml
with:
APP_NAME: www
BUCKET: s3://menthor.io

0 comments on commit e67af28

Please sign in to comment.