2022-09-27 08:47:50 -06:00
|
|
|
name: Docker
|
|
|
|
on:
|
|
|
|
push:
|
2023-07-08 10:37:51 -06:00
|
|
|
branches: [ main, beta ]
|
2022-09-27 08:47:50 -06:00
|
|
|
# Publish semver tags as releases.
|
2023-07-16 13:55:29 -06:00
|
|
|
release:
|
|
|
|
types: [published]
|
2022-09-27 08:47:50 -06:00
|
|
|
|
|
|
|
env:
|
|
|
|
REGISTRY: ghcr.io
|
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
|
2023-01-26 02:41:10 -07:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
|
2022-09-27 08:47:50 -06:00
|
|
|
jobs:
|
2022-09-27 08:53:00 -06:00
|
|
|
docker:
|
2022-09-27 08:47:50 -06:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
2023-01-31 19:30:55 -07:00
|
|
|
id-token: write
|
2023-07-08 10:37:51 -06:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
flavor: [main, sandbox]
|
2022-09-27 08:47:50 -06:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
2023-05-05 10:06:33 -06:00
|
|
|
- name: "Populate frontend version information"
|
|
|
|
run: "cd frontend && ./git.version.sh"
|
2023-01-31 19:30:55 -07:00
|
|
|
- name: Set up depot.dev multi-arch runner
|
|
|
|
uses: depot/setup-action@v1
|
2022-09-27 08:47:50 -06:00
|
|
|
# Login against a Docker registry except on PR
|
|
|
|
# https://github.com/docker/login-action
|
|
|
|
- name: Log into registry ${{ env.REGISTRY }}
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# Extract metadata (tags, labels) for Docker
|
|
|
|
# https://github.com/docker/metadata-action
|
|
|
|
- name: Extract Docker metadata
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v4
|
|
|
|
with:
|
2023-01-25 19:00:13 -07:00
|
|
|
flavor: |
|
2023-07-08 10:37:51 -06:00
|
|
|
# only latest if push has a tag and we're building the "main" flavor
|
|
|
|
latest=${{ github.event_name == 'push' && matrix.flavor == 'main' && contains(github.ref, 'refs/tags/') }}
|
2022-09-27 08:47:50 -06:00
|
|
|
tags: |
|
2023-07-08 10:37:51 -06:00
|
|
|
# if this is a tag'd build, prefix it with the flavor (eg. main-v1.2.3 and sandbox-v1.2.3)
|
|
|
|
type=ref,event=tag,prefix=${{ matrix.flavor }}-
|
|
|
|
# if this is a main branch build, just tag it with the flavor (eg. main and sandbox)
|
|
|
|
type=raw,value=${{ matrix.flavor }},enable=${{ github.ref_name == 'main' }}
|
|
|
|
# if this is a (non main) branch build, tag it with the flavor and branch name (eg. main-branch and sandbox-branch)
|
2023-07-08 10:50:36 -06:00
|
|
|
type=ref,event=branch,prefix=${{ matrix.flavor }}-,enable=${{ github.ref_name != 'main' }}
|
2022-09-27 08:47:50 -06:00
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
# Build and push Docker image with Buildx (don't push on PR)
|
|
|
|
# https://github.com/docker/build-push-action
|
|
|
|
- name: Build and push Docker image
|
2023-01-31 19:30:55 -07:00
|
|
|
uses: depot/build-push-action@v1
|
2022-09-27 08:47:50 -06:00
|
|
|
with:
|
2023-01-31 19:30:55 -07:00
|
|
|
project: vhwr5r7tw1
|
2023-05-19 08:58:37 -06:00
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
2022-09-27 08:47:50 -06:00
|
|
|
context: .
|
2022-09-27 08:53:00 -06:00
|
|
|
file: Dockerfile
|
2022-09-27 08:47:50 -06:00
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
2022-12-17 16:10:19 -07:00
|
|
|
build-args: |
|
2023-07-08 10:37:51 -06:00
|
|
|
FASTEN_ENV=${{ matrix.flavor == 'sandbox' && 'sandbox' || 'prod' }}
|