Skip to content

benjlevesque/actions-docker-gcr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

GitHub Actions for common Docker workflows

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 84.2%
  • Dockerfile 15.8%