cp workflow to .github/workflows #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push to artifact registry | |
description: Composite action to push to Google Artifact Registry | |
inputs: | |
registry: | |
description: | | |
Google Artifact Registry to store docker images in. | |
project: | |
description: | | |
The project which organises the Google Cloud resources. | |
repository: | |
description: | | |
Repository to store the docker image. | |
image_name: | |
description: | | |
The name of the Docker image to be created. | |
tag: | |
description: | | |
Docker image tag. | |
build_path: | |
description: | | |
Path to Dockerfile, which is used to build the image. | |
on: | |
pull_request: | |
runs: | |
using: composite | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: google-github-actions/auth@v1 | |
id: gcloud-auth | |
with: | |
token_format: access_token | |
workload_identity_provider: "projects/304398677251/locations/global/workloadIdentityPools/github/providers/github-provider" | |
service_account: "github-gcr-dev@grafanalabs-workload-identity.iam.gserviceaccount.com" | |
create_credentials_file: false | |
- name: Login to GAR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ inputs.registry }} | |
username: oauth2accesstoken | |
password: ${{ steps.gcloud-auth.outputs.access_token }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.0.0 | |
- name: Build the container | |
uses: docker/build-push-action@v5.0.0 | |
with: | |
context: ${{ inputs.build_path }} | |
push: ${{ github.event_name == 'push' }} | |
tags: | | |
${{ inputs.registry }}/${{ inputs.project }}/${{ inputs.repository }}/${{ inputs.image_name }}:${{ inputs.tag }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |