-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (54 loc) · 1.69 KB
/
build-image.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
name: Build target image
on:
workflow_call:
inputs:
registry:
description: 'Docker Registry'
required: true
type: string
default: 'ghcr.io'
image:
description: 'Image'
required: true
type: string
version:
description: 'Version'
required: true
type: string
platform:
description: 'Platform'
required: true
type: string
arch:
description: 'Architecture'
required: true
type: string
jobs:
build:
name: Build
runs-on: ${{ inputs.platform == 'linux' && (inputs.arch == 'arm64' || inputs.arch == 'arm') && 'self-hosted' || 'ubuntu-latest' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set tags
id: tags
run: |
echo "image=${{ inputs.registry }}/${{ github.repository_owner }}/${{ inputs.image }}-${{ inputs.platform }}-${{ inputs.arch }}" >> $GITHUB_OUTPUT
echo "tag=${{ inputs.version }}" >> $GITHUB_OUTPUT
- name: Login
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: |
docker build \
--tag ${{ steps.tags.outputs.image }}:${{ steps.tags.outputs.tag }} \
--build-arg ARCH=${{ inputs.arch }} \
--build-arg PLATFORM=${{ inputs.platform }} \
--build-arg VERSION=${{ inputs.version }} \
--file etc/docker/Dockerfile .
- name: Push
run: |
docker push ${{ steps.tags.outputs.image }}:${{ steps.tags.outputs.tag }}