-
Notifications
You must be signed in to change notification settings - Fork 156
78 lines (75 loc) · 2.11 KB
/
build_docker.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Build docker image
permissions:
contents: read
on:
workflow_call:
inputs:
image_file:
required: true
type: string
image_name:
required: true
type: string
image_tag:
required: true
type: string
ref:
required: true
type: string
build-args:
required: true
type: string
labels:
required: true
type: string
extra_tags:
required: false
type: string
platforms:
required: false
default: linux/amd64,linux/arm64
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ inputs.image_name }}
jobs:
build_image:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
ref: ${{ inputs.ref }}
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
- name: Login to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Image metadata
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
{{date 'YYYY.MM.DD-HHmm'}}
${{ inputs.image_tag }}
${{ inputs.extra_tags }}
labels: ${{ inputs.labels }}
- name: Build and push
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
with:
context: .
file: ${{ inputs.image_file }}
platforms: ${{ inputs.platforms }}
push: true
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ${{ inputs.build-args }}