Skip to content

chore: remove public IP addresses from all containers #384

chore: remove public IP addresses from all containers

chore: remove public IP addresses from all containers #384

Workflow file for this run

name: AWS deploy
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
skip_tests:
description: 'Skip tests'
default: false
type: boolean
permissions:
id-token: write
contents: read
env:
DJANGO_ENVIRONMENT: DEVELOPMENT
jobs:
linters:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.DEVELOPMENT.txt
- name: Run linters
uses: pre-commit/[email protected]
tests:
runs-on: ubuntu-latest
services:
postgres:
# Docker Hub image
image: postgres:12.13
# Provide the password for postgres
env:
POSTGRES_PASSWORD: aiarena
POSTGRES_USER: aiarena
POSTGRES_DATABASE: test_aiarena
POSTGRES_ROOT_PASSWORD: aiarena
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- uses: shogo82148/actions-setup-redis@v1
with:
redis-version: '6.x'
- run: redis-cli ping
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.DEVELOPMENT.txt
- name: Grant aiarena user full access
env:
PORT: ${{ job.services.postgres.ports[5432] }}
run: |
PGPASSWORD="aiarena" psql -Uaiarena --host="127.0.0.1" --port "$PORT" -c "GRANT ALL PRIVILEGES ON DATABASE aiarena TO aiarena;";
- name: Run Tests
if: ${{ !inputs.skip_tests }}
env:
NOFAKE_REDIS: 1
run: |
python manage.py test --noinput
prepare-images:
if: github.event_name != 'pull_request'
name: Build and push production image to ECR
runs-on: ubuntu-latest
outputs:
status_message_id: ${{ steps.slack.outputs.message_id }}
images: ${{ steps.prepare_images.outputs.images }}
steps:
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::315513665747:role/aiarena-DeployRole-NUZWXPWHC0MZ
aws-region: eu-central-1
- name: Confirm AWS identity
run: aws sts get-caller-identity
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install Dependencies
run: |
pip install -r ./requirements.LOCAL.txt
- name: Prepare image
id: prepare_images
env:
BUILD_NUMBER: ${{ github.run_number }}
MAINTENANCE_MODE: ${{ vars.MAINTENANCE_MODE }}
run: ./run.py prepare-images
deploy:
if: github.event_name != 'pull_request'
name: Deploy to ECS
runs-on: ubuntu-latest
needs: [ linters, tests, prepare-images ]
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install Dependencies
run: |
pip install -r ./requirements.LOCAL.txt
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::315513665747:role/aiarena-DeployRole-NUZWXPWHC0MZ
aws-region: eu-central-1
- name: Deploy
env:
BUILD_NUMBER: ${{ github.run_number }}
PREPARED_IMAGES: ${{ needs.prepare-images.outputs.images }}
MAINTENANCE_MODE: ${{ vars.MAINTENANCE_MODE }}
run: ./run.py ecs
- name: Monitor deployment
run: ./run.py monitor-ecs