Skip to content

Commit

Permalink
Add Docker build and push called workflow (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcurtis authored Jul 4, 2024
1 parent 1da9ccd commit f6d9774
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build and Push Called Workflow

on:
workflow_call:
inputs:
build_args:
required: false
type: string
cache_from:
required: true
type: string
cache_to:
required: false
type: string
default: "type=inline"
context:
required: false
type: string
default: "."
file:
required: false
type: string
default: ""
push:
required: false
type: boolean
default: true
registry:
required: true
type: string
service_account:
required: true
type: string
tags:
required: true
type: string
workload_identity_provider:
required: true
type: string

jobs:
build-and-push:
name: Build and push
runs-on: ubuntu-latest

steps:
# GitHub - Checkout
# https://github.com/marketplace/actions/checkout

- name: Checkout
uses: actions/checkout@v4.1.7

# Google Cloud Platform - Create Credentials
# https://github.com/marketplace/actions/authenticate-to-google-cloud

- name: Create credentials
id: create_credentials
uses: google-github-actions/auth@v2.1.3
with:
token_format: access_token
service_account: ${{ inputs.service_account }}
workload_identity_provider: ${{ inputs.workload_identity_provider }}
access_token_lifetime: 300s

# Docker Buildx
# https://github.com/marketplace/actions/docker-setup-buildx

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0

# Docker Login
# https://github.com/marketplace/actions/docker-login

- name: Login to Google Artifact Registry
uses: docker/login-action@v3.2.0
with:
registry: ${{ inputs.registry }}
username: oauth2accesstoken
password: ${{ steps.create_credentials.outputs.access_token }}


# Build and Push Docker to Google Artifact Registry
# https://github.com/marketplace/actions/build-and-push-docker-images

- name: Build and push to Google Artifact Registry
uses: docker/build-push-action@v5.3.0
with:
tags: ${{ inputs.tags }}
cache-from: ${{ inputs.cache_from }}
cache-to: ${{ inputs.cache_to }}
context: ${{ inputs.context }}
file: ${{ inputs.file}}
build-args: ${{ inputs.build_args }}
push: ${{ inputs.push }}

0 comments on commit f6d9774

Please sign in to comment.