fix: Dockerfile cache directories #119
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: Github Action Continuous Integration (CI) pipeline | |
on: | |
- push | |
jobs: | |
python-code-checks: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- check-name: ruff | |
check-command: ruff check --format github . | |
- check-name: black | |
check-command: black --check . | |
# TODO: configure mypy cache | |
- check-name: mypy | |
check-command: mypy | |
name: ${{ matrix.check-name }} | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: pip install poetry==1.5.0 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version-file: "pyproject.toml" | |
cache: 'poetry' | |
- run: poetry install --with dev | |
- run: poetry run ${{ matrix.check-command }} | |
docker: | |
runs-on: ubuntu-22.04 | |
needs: | |
- python-code-checks | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: docker/setup-buildx-action@v2 | |
- if: github.ref_name == github.event.repository.default_branch | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
- uses: docker/build-push-action@v4 | |
with: | |
push: ${{ github.ref_name == github.event.repository.default_branch }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64 | |
# TODO: build other targets? | |
target: api | |
# NOTE: see https://docs.docker.com/build/cache/backends/gha/#scope | |
cache-from: | | |
type=gha,scope=${{ github.ref_name }} | |
type=gha,scope=${{ github.base_ref }} | |
type=gha,scope=${{ github.event.repository.default_branch }} | |
cache-to: type=gha,mode=max,scope=${{ github.ref_name }} |