Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Push to Google Container Registry (GCR) from GitHub Actions
name: Docker Image CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build and push Docker images
uses: docker/build-push-action@v1.1.0
with:
# Username used to log in to a Docker registry. If not set then no login will occur
username: _json_key
# Password or personal access token used to log in to a Docker registry. If not set then no login will occur
password: ${{ secrets.GCLOUD_SERVICE_KEY }}
# Server address of Docker registry. If not set then will default to Docker Hub
registry: gcr.io
# Docker repository to tag the image with
repository: ${{ secrets.GOOGLE_PROJECT_ID }}/<DOCKER IMAGE NAME>
# Comma-delimited list of tags. These will be added to the registry/repository to form the image's tags
tags: latest
# Automatically tags the built image with the git reference as per the readme
tag_with_ref: true
# Automatically tags the built image with the git short SHA as per the readme
tag_with_sha: true
# Comma-delimited list of labels to add to the built image
labels: github-action-build
# Whether to push the image
push: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.