Skip to content

Merge pull request #6 from haikoschol/dependabot/pip/pip-aed9f6bbcd #22

Merge pull request #6 from haikoschol/dependabot/pip/pip-aed9f6bbcd

Merge pull request #6 from haikoschol/dependabot/pip/pip-aed9f6bbcd #22

Workflow file for this run

name: Do All The Things
on:
push:
branches: [ main ]
jobs:
collectstatic-and-migrate-db:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python -
- name: Install dependencies with Poetry
run: |
poetry install --no-root --without=dev
- name: Collect static files
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: |
poetry run python manage.py collectstatic --noinput
- name: Sync static files to AWS S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'auto'
run: |
aws s3 sync --endpoint-url ${{ vars.R2_ENDPOINT_URL }} collectedstatic/ s3://coa-static/ --delete
- name: Apply database migrations
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: |
poetry run python manage.py migrate
build-docker-image:
needs: collectstatic-and-migrate-db
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Get the short SHA
id: sha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push the Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/cats-of-asia:${{ steps.sha.outputs.sha }}
ghcr.io/${{ github.repository_owner }}/cats-of-asia:latest