-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (60 loc) · 1.98 KB
/
docker_build.yaml
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
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Build and push docker image
on:
workflow_call:
inputs:
base_image_name:
required: true
type: string
description: Base name of the image to build and push
outputs:
image_name:
description: String that represents the built image name
value: ${{ jobs.docker_build_and_push.outputs.image_name }}
jobs:
docker_build_and_push:
runs-on: ubuntu-latest
outputs:
image_name: ${{ fromJson(steps.meta.outputs.json).tags[0] }}
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
large-packages: false
docker-images: false
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
persist-credentials: false
# lfs=true is not enough, see https://stackoverflow.com/questions/61463578/github-actions-actions-checkoutv2-lfs-true-flag-not-converting-pointers-to-act
- name: Pull LFS Objects
run: git lfs pull
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GAR
uses: docker/login-action@v3
with:
registry: europe-west3-docker.pkg.dev
username: _json_key
password: ${{ secrets.GAR_JSON_KEY }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.base_image_name }}
tags: |
type=sha
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ inputs.base_image_name }}:latest
cache-to: type=inline