-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
68 lines (62 loc) · 2.21 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
name: google-artifact-registry-action
description: A GitHub action that authenticates to Google Artifact Registry, builds a Docker image and pushes it to an Artifact Registry repository.
inputs:
image:
required: true
description: Full Docker image name to build and push, including the registry, repository and tag
service_account:
required: true
description: GCP service account used to authenticate to Google Cloud
workload_identity_provider:
required: true
description: GCP workload identity provider used to authenticate to Google Cloud
context:
required: false
description: Build's context is the set of files located in the specified PATH or URL
file:
required: false
default: Dockerfile
description: Path to the `Dockerfile` to build
build-args:
required: false
default: ""
description: The `build-args` to pass to `docker/build-push-action`
secrets:
required: false
default: ""
description: The `secrets` to pass to `docker/build-push-action`
runs:
using: composite
steps:
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v1
with:
token_format: access_token
workload_identity_provider: ${{ inputs.workload_identity_provider }}
service_account: ${{ inputs.service_account }}
- name: Get Docker registry from image
id: get_docker_registry
run: |
registry=$(echo ${{ inputs.image }} | cut -d / -f 1)
echo "registry=$registry" >> $GITHUB_OUTPUT
shell: bash
- name: Log into Google Artifact Registry
uses: docker/login-action@v2
with:
registry: ${{ steps.get_docker_registry.outputs.registry }}
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ inputs.context }}
file: ${{ inputs.file }}
build-args: ${{ inputs.build-args }}
secrets: ${{ inputs.secrets }}
push: true
tags: ${{ inputs.image }}
cache-from: type=gha
cache-to: type=gha,mode=max