-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yaml
90 lines (83 loc) · 2.66 KB
/
action.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
79
80
81
82
83
84
85
86
87
88
89
90
name: "Build and push to ghcr.io"
description: >
This composite action builds a Docker image, tags it with the current git
branch/tag ref, and pushes it to ghcr.io.
inputs:
github_token:
description: "The GitHub token to use for authentication."
required: true
image:
description: "The name of the Docker image to build."
required: true
dockerfile:
description: "The name of the Dockerfile to build."
required: false
default: "Dockerfile"
context:
description: "The build context to use."
required: false
default: "."
push:
description: "Whether to push the image to ghcr.io."
required: false
default: "true"
platforms:
description: "List of target platforms for build"
required: false
target:
description: "Name of target stage to build"
required: false
build-args:
description: "List of build-time variables"
required: false
additional-tags:
description: "List of additional tags to add to built image"
required: false
outputs:
tag:
description: "The tag of the Docker image that was built."
value: ${{ steps.tag.outputs.tag }}
fully_qualified_image_digest:
description: "A complete, unique, immutable identifier for the built image, including the registry and digest"
value: "ghcr.io/${{ inputs.image }}@${{ steps.build.outputs.digest }}"
runs:
using: "composite"
steps:
- name: Define the tag
id: tag
shell: bash
run: echo "tag=`bash ${{ github.action_path }}/docker-tag.sh`" >> ${GITHUB_OUTPUT}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ inputs.image }}
tags: |
type=raw,${{ steps.tag.outputs.tag }}
${{ inputs.additional-tags }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
if: fromJSON(inputs.push) == true
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.github_token }}
- name: Build and push
id: build
uses: docker/build-push-action@v6
with:
context: "${{ inputs.context }}"
file: "${{ inputs.dockerfile }}"
build-args: "${{ inputs.build-args }}"
target: "${{ inputs.target }}"
push: ${{ fromJSON(inputs.push) == true }}
platforms: ${{ inputs.platforms }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max