Skip to content

Instantly share code, notes, and snippets.

@davidcorbin
Created May 24, 2020 18:13
Show Gist options
  • Save davidcorbin/0d59860d58afd6f43cfca5b4150eff20 to your computer and use it in GitHub Desktop.
Save davidcorbin/0d59860d58afd6f43cfca5b4150eff20 to your computer and use it in GitHub Desktop.
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/[email protected]
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