Skip to content

Latest commit

 

History

History
92 lines (68 loc) · 3.98 KB

README.md

File metadata and controls

92 lines (68 loc) · 3.98 KB

actions-docker-gcr

GitHub Actions for common Docker workflows (Forked from https://github.com/urcomputeringpal/actions-docker)

Usage

Google Container Registry Setup

# Linux
cat path-to/key.json | base64 -w 0

# MacOS
cat path-to/key.json | base64 -b 0
  • That's it! The GitHub Actions in this repository read this Secret and provide the correct values to the Docker daemon by default if present. If a Secret isn't present, build may succeed but push will return an error!

Build and push images for each commit

Add the following to .github/workflows/docker.yaml:

name: Docker

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1

      - name: Docker Build
        uses: benjlevesque/actions-docker-gcr/build@v1.1

      - name: Docker Push
        uses: benjlevesque/actions-docker-gcr/push@v1.1
        with:
          gcloud_key: ${{ secrets.GCLOUD_SERVICE_ACCOUNT_KEY }}

Specify a different Registry, Project & image name

    [...]
    steps:
      - uses: actions/checkout@v1

      - name: Docker Build
        uses: benjlevesque/actions-docker-gcr/build@v1.1
        with:
          image: my-project/my-image
          registry: eu.gcr.io

      - name: Docker Push
        uses: benjlevesque/actions-docker-gcr/push@v1.1
        with:
          image: my-project/my-image
          registry: eu.gcr.io
          gcloud_key: ${{ secrets.GCLOUD_SERVICE_ACCOUNT_KEY }}

Parameters

Build

parameter description required default
registry The registry to upload to. false gcr.io
image The name of image to build. false $GITHUB_REPOSITORY
tag The tag of the image. false $GITHUB_SHA
latest If true, will also add latest tag true true
args Additional args for docker false
dockerfile The Dockerfile to use false Dockerfile

Push

parameter description required default
registry The registry to upload to. false gcr.io
image The name of image to build. false $GITHUB_REPOSITORY
tag The tag of the image. false $GITHUB_SHA
latest If true, will also add latest tag true true
gcloud_key A GCloud service account json key, base64 encoded. Should be stored in a secret! true