maybe debug ci episode 5002 #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: 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 }} | |
run: | | |
aws s3 sync --endpoint-url ${{ vars.R2_ENDPOINT_URL }} collectedstatic/ s3://coa-static/ --delete --debug | |
- 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 | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Get the short SHA | |
id: sha | |
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)" | |
- 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 |