diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 84d36e7..fe9ab66 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,8 @@ on: permissions: # Checkout repository contents: read + # Push container images + packages: write jobs: build: @@ -30,7 +32,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Build image + - name: Build image for tests id: build uses: docker/build-push-action@v5 with: @@ -71,3 +73,34 @@ jobs: --workdir /usr/local/src ${{ steps.build.outputs.imageid }} /bin/sh -c 'apt-get install -y mypy python3-pytest && mypy --show-error-codes .' + + - name: Docker meta + id: meta + if: ${{ github.event_name != 'pull_request' || always() }} + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository }} + tags: | + type=edge + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Login to GitHub Container Registry + if: ${{ github.event_name != 'pull_request' || always() }} + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image + if: ${{ github.event_name != 'pull_request' || always() }} + uses: docker/build-push-action@v5 + with: + file: Containerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}