-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (49 loc) · 1.81 KB
/
build-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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