Skip to content

Merge pull request #14 from plbalmeida/main #90

Merge pull request #14 from plbalmeida/main

Merge pull request #14 from plbalmeida/main #90

Workflow file for this run

name: CI/CD Workflow
on:
push:
branches:
- main
- destroy-infra
jobs:
build:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/destroy-infra'
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
make install
test:
needs: build
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/destroy-infra'
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
infra:
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
- name: Terraform Init
run: terraform init
working-directory: ./infra/main-infrastructure
- name: Conditional Terraform Apply or Destroy
run: |
if [ "${{ github.ref }}" == "refs/heads/destroy-infra" ]; then
echo "Destroying infrastructure..."
terraform destroy -auto-approve
else
echo "Applying infrastructure..."
terraform apply -auto-approve
fi
working-directory: ./infra/main-infrastructure
codebuild:
needs: infra
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/destroy-infra'
steps:
- uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Start AWS CodeBuild
run: |
make codebuild