Add cd workflow #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ "main" ] | |
workflow_dispatch: | |
jobs: | |
build-frontend: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: frontend | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
cache-dependency-path: frontend/package-lock.json | |
- name: Install | |
run: npm install | |
- name: Lint | |
run: npm run lint | |
- name: Format check | |
run: npm run format:check | |
- name: Test | |
run: npm run test | |
- name: Build | |
run: npm run build | |
- name: Upload Frontend Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: frontend-build | |
path: frontend/dist | |
retention-days: 1 | |
if-no-files-found: error | |
deploy-infrastructure: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: infrastructure | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download Frontend Build Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: frontend-build | |
path: frontend/dist | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: npm | |
cache-dependency-path: infrastructure/package-lock.json | |
- name: Install AWS CLI | |
run: npm install -g aws-cdk | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: eu-central-1 | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Install | |
run: npm install | |
- name: Lint | |
run: npm run lint | |
- name: Format check | |
run: npm run format:check | |
- name: Test | |
run: npm run test | |
- name: Build | |
run: npm run build | |
- name: CDK Deploy | |
run: npm run deploy -- --require-approval never |