Merge pull request #17 from Food-fusion-Fiap/CAVAh-patch-1 #19
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: Deploy to AWS | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
inputs: | |
confirm: | |
description: 'Type "yes" to confirm destroy action' | |
required: true | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
jobs: | |
terraform_apply: | |
name: 'Terraform Apply' | |
runs-on: ubuntu-latest | |
if: github.event_name != 'workflow_dispatch' && github.event.inputs.confirm != 'yes' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v1 | |
with: | |
terraform_version: 1.8.2 | |
- name: Terraform Init | |
run: terraform init | |
- name: Terraform Plan | |
run: terraform plan | |
- name: Clone repository | |
run: | | |
git clone https://github.com/Food-fusion-Fiap/lambda-auth | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install --production | |
working-directory: lambda-auth | |
- name: Build TypeScript | |
run: npm run build | |
working-directory: lambda-auth | |
- name: Create ZIP file | |
run: zip -r lambda_function.zip . | |
working-directory: lambda-auth/dist | |
- name: Terraform Apply | |
run: terraform apply -auto-approve | |
env: | |
TF_VAR_jwt_secret: ${{ secrets.JWT_SECRET }} | |
terraform_destroy: | |
name: 'Terraform Destroy' | |
runs-on: ubuntu-latest | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.confirm == 'yes' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v1 | |
with: | |
terraform_version: 1.8.2 | |
- name: Terraform Init | |
run: terraform init | |
- name: Terraform Destroy | |
run: terraform destroy -auto-approve |