Skip to content

rgarlik/gcp-artifact-registry-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GCP Artifact Registry Template

This project contains a GitHub Action that builds a Docker image and deploys it to Google Cloud's Artifact Registry.

The workflow is located in .github/workflows/build-and-deploy.yml. Copying the YAML file over into your own project is enough to get it working.

The action deploys the Docker image under two tags. The first one is latest and the other one is the current commit's SHA number.

Prerequisites

Do the following in your Google Cloud project for this GitHub Action to work:

  • Enable the Artifact Registry service
  • Create a service account with the Artifact Registry Writer (roles/artifactregistry.writer) role
  • Create a repository in Artifact Registry with the format of Docker.

Configuration

The following variables need to be configured through GitHub's settings page.

Variable Description
PROJECT_NAME Your Google Cloud project name
IMAGE_NAME Your Docker image name (used both locally and in the registry)
REPOSITORY Your Artifact Registry repository
REGION The region of the repository

The following secrets are used by the action, mostly to authenticate through google-github-actions/auth. Secrets can only be added through the settings page. This workflow uses the credentials_json method of authentication which is less secure than workload_identity_provider (though it's easier to set up). If you'd rather use Indentity providers, check out the commented out section in the YAML file or read about the alternative method here.

Secret Description
GCP_CREDENTIALS Your service account's credentials