1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-31 11:32:55 +02:00
immich/.github/workflows/docker.yml
bo0tzz c90a88fb17
feat(ci): Consolidate docker build workflow (#1374)
* Consolidate docker build into single workflow

* ci: Only push to altran1502 on release

* ci: Tweaks

* feat(ci): Remove metadata key from permissions

* feat(ci): workaround for buildx regression

* Drop buildkit version to workaround regression

* Revert "Drop buildkit version to workaround regression"

This reverts commit 79adadb2d3.

* Use repo owner name for ghcr login

* feat(ci): Skip docker push on PRs from fork

* feat(ci): Remove explicit permissions config

* temp: Skip docker hub login

* Revert "temp: Skip docker hub login"

This reverts commit e92864d1a3.

* Remove fetch-depth from checkout action
2023-01-21 09:38:27 -06:00

90 lines
2.8 KiB
YAML

name: Build and Push Docker Images
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
jobs:
build_and_push:
runs-on: ubuntu-latest
strategy:
# Prevent a failure in one image from stopping the other builds
fail-fast: false
matrix:
include:
- context: "server"
image: "immich-server"
- context: "web"
image: "immich-web"
- context: "machine-learning"
image: "immich-machine-learning"
- context: "nginx"
image: "immich-proxy"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.2.1
# Workaround to fix error:
# failed to push: failed to copy: io: read/write on closed pipe
# See https://github.com/docker/build-push-action/issues/761
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Login to Docker Hub
# Only push to Docker Hub when making a release
if: ${{ github.event_name == 'release' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
# Skip when PR from a fork
if: ${{ !github.event.pull_request.head.repo.fork }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate docker image tags
id: metadata
uses: docker/metadata-action@v4
with:
flavor: |
# Disable latest tag
latest=false
images: |
name=ghcr.io/${{ github.repository_owner }}/${{matrix.image}}
name=altran1502/${{matrix.image}},enable=${{ github.event_name == 'release' }}
tags: |
# Tag with branch name
type=ref,event=branch
# Tag with pr-number
type=ref,event=pr
# Tag with git tag on release
type=ref,event=tag
type=raw,value=release,enable=${{ github.event_name == 'release' }}
- name: Build and push image
uses: docker/build-push-action@v3.3.0
with:
context: ${{ matrix.context }}
platforms: linux/arm/v7,linux/amd64,linux/arm64
# Skip pushing when PR from a fork
push: ${{ !github.event.pull_request.head.repo.fork }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.metadata.outputs.tags }}