Format with pre-commit #28
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: development | |
on: | |
pull_request: | |
branches: | |
- develop | |
push: | |
branches: | |
- develop | |
jobs: | |
build-test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:13.3 | |
env: | |
POSTGRES_USER: db_user | |
POSTGRES_PASSWORD: db_password | |
POSTGRES_DB: db_test | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
cache: "pip" | |
- name: Install Python dependencies | |
run: python -m pip install -r requirements.txt | |
- name: Run isort | |
run: isort --check-only --profile=black . | |
- name: Run black | |
run: black --check . | |
- name: Run flake8 | |
run: flake8 --ignore=E501,W503,F401 . | |
- name: Unit Tests and Integration Tests | |
env: | |
DATABASE_TEST_URL: postgresql://db_user:db_password@localhost/db_test | |
run: python -m flask tests | |
deploy-service: | |
needs: build-test | |
runs-on: ubuntu-latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: "us-east-1" | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Login to Docker Hub | |
id: docker_hub_auth | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build Docker Image | |
id: build_docker | |
run: | | |
docker compose build api_service | |
# Add tag | |
docker tag api_image:latest ${{ secrets.DOCKERHUB_USERNAME }}/api_image:latest | |
- name: Push Docker Image | |
id: push_images | |
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/api_image:latest | |
- name: Deploy to AWS CloudFormation | |
uses: aws-actions/aws-cloudformation-github-deploy@v1 | |
with: | |
name: MyStackEC2 | |
template: myStack.yaml | |
parameter-overrides: "MyParam1=myValue,MyParam2=${{ secrets.MY_SECRET_VALUE }}" |