-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
102 lines (82 loc) · 2.4 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
name: 'Build Docker image'
description: 'Build Docker image from cache using a registry'
inputs:
image:
description: 'Image name'
required: false
default: ${{ github.repository }}
dockerfile:
description: 'Path to dockerfile'
required: false
default: 'Dockerfile'
context:
description: 'Directory to build from'
required: false
default: '.'
target:
description: 'Target stage to build'
required: false
registry:
description: 'Packages registry to use'
required: false
default: 'ghcr.io'
registry-user:
description: 'Username to log into registry with'
required: false
default: ${{ github.actor }}
registry-password:
description: 'Password to log into registry with'
required: true
outputs:
tagged-image:
description: 'Created image name with tag'
value: ${{ steps.post.outputs.tagged-image }}
version:
description: 'Generated Docker image version'
value: ${{steps.meta.outputs.version}}
tags:
description: 'Generated Docker tags'
value: ${{steps.meta.outputs.tags}}
labels:
description: 'Generated Docker labels'
value: ${{steps.meta.outputs.labels}}
annotations:
description: 'Generated annotations'
value: ${{steps.meta.outputs.annotations}}
json:
description: 'JSON output of tags and labels'
value: ${{steps.meta.outputs.json}}
runs:
using: composite
steps:
- uses: actions/checkout@v4
if: ${{ !env.GITHUB_WORKSPACE || !env.GITHUB_SHA }}
- uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.registry-user }}
password: ${{ inputs.registry-password }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ inputs.registry }}/${{ inputs.image }}
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
id: build
with:
context: ${{ inputs.context }}
push: true
target: ${{ inputs.target }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: 'Set variables'
id: post
env:
JSON: ${{ steps.meta.outputs.json }}
shell: bash
# language=bash
run: |
firstTag=$(echo $JSON | jq -r '.tags[0]')
echo "tagged-image=$firstTag" >> $GITHUB_OUTPUT