-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker build and push called workflow (#27)
- Loading branch information
1 parent
1da9ccd
commit f6d9774
Showing
1 changed file
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |