-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
155 lines (129 loc) · 4.78 KB
/
action.yml
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: build-push
description: >
Builds Docker images, adds tags/labels/annotations, and pushes them to a registry, running rootless in ARC on Kubernetes.
author: aleskxyz
inputs:
image_name:
description: Name of the Docker image to be built and pushed.
required: true
registry_address:
description: URL of the container registry where the image will be pushed.
required: true
registry_username:
description: Username for authentication with the container registry.
required: true
registry_password:
description: Password for authentication with the container registry.
required: true
context:
description: The directory path used as the build context. Default is the current directory (`.`).
required: false
default: './'
dockerfile_path:
description: Location of the Dockerfile. Defaults to `./Dockerfile`.
required: false
default: 'Dockerfile'
flavor:
description: >
Specifies the tagging strategy. For options, see Docker Metadata Action documentation at
https://github.com/docker/metadata-action?tab=readme#flavor-input.
required: false
tags:
description: >
Defines how the image is tagged. For detailed configuration, refer to Docker Metadata Action documentation at
https://github.com/docker/metadata-action?tab=readme#tags-input.
required: false
default: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=schedule,pattern={{date 'YYYYMMDD-hhmmss'}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
labels:
description: Custom labels to apply to the built image, separated by newlines.
required: false
annotations:
description: Additional annotations for the image, separated by newlines.
required: false
archs:
description: CPU architectures to target during the build, separated by commas.
required: false
platforms:
description: Target platforms for the image build, separated by commas.
required: false
build_args:
description: >
Build-time variables in the form arg_name=arg_value. Separate multiple arguments with newlines.
These are passed to Docker build with --build-arg.
required: false
buildah_extra_args:
description: Additional arguments for the `buildah bud` command, separated by newlines.
required: false
oci:
description: >
Sets the image format. true for OCI format, false for Docker format. Default is false.
required: false
default: false
push_extra_args:
description: Extra arguments for the `podman push` command, separated by newlines.
required: false
outputs:
push_result:
description: JSON string with the digest and registry paths for pushed images.
value: ${{ toJSON(steps.push.outputs) }}
runs:
using: composite
steps:
- name: Export BUILDAH_ISOLATION Environment Variable
run: echo "BUILDAH_ISOLATION=chroot" >> $GITHUB_ENV
shell: bash
- name: Setup Build Environment
run: ${GITHUB_ACTION_PATH}/setup_runner.sh
shell: bash
env:
INPUT_ARCHS: ${{ inputs.archs }}
INPUT_PLATFORMS: ${{ inputs.platforms }}
- name: Log in to registry
uses: redhat-actions/podman-login@v1
with:
registry: ${{ inputs.registry_address }}
username: ${{ inputs.registry_username }}
password: ${{ inputs.registry_password }}
- name: Generate Docker Metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: ${{ inputs.registry_address }}/${{ inputs.image_name }}
tags: ${{ inputs.image_tags }}
flavor: ${{ inputs.flavor }}
labels: ${{ inputs.labels }}
annotations: ${{ inputs.annotations }}
- name: Build Docker Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
oci: ${{ inputs.oci }}
containerfiles: ${{ inputs.dockerfile_path }}
context: ${{ inputs.context }}
archs: ${{ inputs.archs }}
platforms: ${{ inputs.platforms }}
build-args: $${{ inputs.build_args }}
extra-args: ${{ inputs.buildah_extra_args }}
layers: true
- name: Push Image to Registry
id: push
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
extra-args: ${{ inputs.push_extra_args }}
- name: Print Push Result
run: "echo 'Push Result: ${{ toJSON(steps.push.outputs) }}'"
shell: bash
branding:
icon: check
color: blue