ci: push #10
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: 'Build and Deploy' | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
build_deploy: | |
runs-on: 'ubuntu-22.04' | |
strategy: | |
matrix: | |
# TODO: These multi-stage builds are inefficient. This probably needs Bake: | |
# https://stackoverflow.com/a/65583728/5719930 | |
image: | |
[ | |
{ dockerfile: './docker/Dockerfile.pnpm', target: 'prep' }, | |
{ dockerfile: './docker/Dockerfile.pnpm', target: 'home' }, | |
{ context: 'docker', dockerfile: 'Dockerfile.postgres', tag: 'postgres' } | |
] | |
steps: | |
# Docs: https://github.com/docker/metadata-action | |
- name: Generate Docker tags | |
uses: docker/metadata-action@v5 | |
with: | |
images: 'hackbu/${{ matrix.image.target || matrix.image.tag }}' | |
tags: type=sha | |
flavor: latest=true | |
# Docs: https://github.com/docker/setup-qemu-action | |
- name: 'Setup QEMU to emulate other platforms' | |
uses: 'docker/setup-qemu-action@v3' | |
# Docs: https://github.com/docker/setup-buildx-action | |
- name: 'Setup Docker Buildx' | |
uses: 'docker/setup-buildx-action@v3' | |
# Docs: https://github.com/docker/login-action | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# Docs: https://github.com/docker/build-push-action | |
- name: 'Build and push' | |
uses: 'docker/build-push-action@v5' | |
with: | |
context: '{{defaultContext}}:${{ matrix.image.context }}' | |
file: '${{ matrix.image.dockerfile }}' | |
target: '${{ matrix.image.target }}' | |
platforms: 'linux/amd64,linux/arm64' | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.tags }} | |
push: true |