-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
67 lines (67 loc) · 2.1 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
name: Build and Push Container Image
description: Build and push Docker image to Google Artifact Registry
inputs:
name:
description: The name of the image to build
required: true
context:
description: The Docker context
required: true
default: .
file:
description: The Dockerfile to build
required: true
default: Dockerfile
project:
description: The Google Cloud Platform project to push to
required: true
repository:
description: The repository in Google Artifact Registry to push to
required: true
region:
description: The Google Cloud Platform region where the repository is located
required: true
default: europe-west3
serviceAccountKey:
description: The Service Account key to authenticate with Google Artifact Registry
required: true
build-args:
description: "List of build-time variables"
required: false
tags:
description: Image tag generation parameters
required: false
outputs:
image:
description: The pushed image including the tag
value: ${{steps.push.outputs.image}}
runs:
using: composite
steps:
- name: Generate metadata
id: meta
shell: bash
run: |
echo "::set-output name=registry::${{inputs.region}}-docker.pkg.dev"
echo "::set-output name=image::${{inputs.region}}-docker.pkg.dev/${{inputs.project}}/${{inputs.repository}}/${{inputs.name}}"
- name: Authenticate Docker with Artifact Registry
uses: docker/login-action@v2
with:
registry: ${{steps.meta.outputs.registry}}
username: _json_key
password: ${{inputs.serviceAccountKey}}
- name: Generate metadata for Docker
id: image
uses: docker/metadata-action@v4
with:
images: ${{steps.meta.outputs.image}}
tags: ${{inputs.tags}}
- name: Build image and push to Artifact Registry
uses: docker/build-push-action@v3
with:
context: ${{inputs.context}}
file: ${{inputs.file}}
build-args: ${{inputs.build-args}}
push: true
tags: ${{steps.image.outputs.tags}}
labels: ${{steps.image.outputs.labels}}