fix(*): infra file created and .yml updated #7
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/CD Workflow | |
on: | |
push: | |
workflow_dispatch: | |
inputs: | |
destroy: | |
description: 'Destroy Terraform resources (true to destroy)' | |
required: true | |
default: 'false' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.8', '3.9', '3.10'] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
make install | |
- name: Lint | |
run: | | |
make lint | |
- name: Format | |
run: | | |
make format | |
- name: Test | |
run: | | |
make test | |
- name: Start the server | |
run: | | |
python src/main.py & sleep 10 | |
- name: Load Test | |
run: | | |
make load-test | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v1 | |
- name: Terraform Init | |
run: terraform init | |
working-directory: ./infra | |
- name: Terraform Apply | |
run: terraform apply -auto-approve | |
working-directory: ./infra | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_SESSION_TOKEN_ID: ${{ secrets.AWS_SESSION_TOKEN_ID }} | |
AWS_DEFAULT_REGION: us-east-1 | |
- name: Start AWS CodeBuild | |
run: | | |
aws codebuild start-build --project-name practical-mlops-ch1-exercises | |
destroy: | |
runs-on: ubuntu-latest | |
needs: build | |
if: ${{ github.event.inputs.destroy == 'true' }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v1 | |
- name: Terraform Init | |
run: terraform init | |
working-directory: ./infra | |
- name: Terraform Destroy | |
run: terraform destroy -auto-approve | |
working-directory: ./infra | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_SESSION_TOKEN_ID: ${{ secrets.AWS_SESSION_TOKEN_ID }} | |
AWS_DEFAULT_REGION: us-east-1 |