-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/build push image workflow (#16)
* Add Workflow for building and pushing images to GAR with a self hosted runner
- Loading branch information
Showing
2 changed files
with
76 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,61 @@ | ||
name: Build and Push to GCP Artifact Registry Resuable Workflow | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
region: | ||
description: 'Region where the Artifact Registry is located' | ||
type: string | ||
required: true | ||
dockerfile_path: | ||
description: 'Path to the Dockerfile' | ||
type: string | ||
required: true | ||
docker_image_tag: # It should be in the form as mentioned in our internal docs. Just pass insensitive data here like huggingface-text-generation-inference-${accelerator}.${version}:latest | ||
description: 'Docker Image Tag' | ||
type: string | ||
required: true | ||
gcp_artifact_registry_repository: | ||
description: 'GCP Artifact Registry Repository' | ||
type: string | ||
required: true | ||
secrets: | ||
GCP_SERVICE_ACCOUNT_JSON_KEY: | ||
description: 'Service Account' | ||
required: true | ||
GCP_PROJECT_ID: | ||
description: 'GCP Project ID' | ||
required: true | ||
|
||
jobs: | ||
build-push-image-job: | ||
name: Build and Push Docker Image to GCP Artifact Registry | ||
runs-on: [intel-cpu, 8-cpu, ci] | ||
steps: | ||
- id: 'auth' | ||
name: 'Authenticate with Google Cloud' | ||
uses: 'google-github-actions/[email protected]' | ||
with: | ||
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_JSON_KEY }} | ||
|
||
- id: 'setup-buildx' | ||
name: 'Set up Docker Buildx' | ||
uses: 'docker/[email protected]' | ||
|
||
- id: 'docker-login' | ||
name: 'Docker Login' | ||
uses: 'docker/[email protected]' | ||
with: | ||
registry: ${{ inputs.region }}-docker.pkg.dev | ||
username: _json_key | ||
password: ${{ secrets.GCP_SERVICE_ACCOUNT_JSON_KEY }} | ||
|
||
- id: 'build-and-push' | ||
name: 'Build and Push Docker Image' | ||
uses: 'docker/[email protected]' | ||
with: | ||
file: ${{ inputs.dockerfile_path }} # Read more about it here: https://github.com/marketplace/actions/build-and-push-docker-images#customizing | ||
tags: ${{ inputs.region }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ inputs.gcp_artifact_registry_repository }}/${{ inputs.docker_image_tag }} | ||
push: true | ||
|
||
|
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,15 @@ | ||
name: Test Build and Push Image Reusable Workflow | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test-reusable-workflow: | ||
uses: ./.github/workflows/build-push-image.yml | ||
with: | ||
region: us-central1 | ||
dockerfile_path: ./containers/pytorch/training/gpu/2.1/transformers/4.37.2/py310/Dockerfile | ||
docker_image_tag: huggingface-pytorch-training-gpu-2.1.transformers.4.37.2.py310:latest | ||
gcp_artifact_registry_repository: deep-learning-images | ||
secrets: | ||
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | ||
GCP_SERVICE_ACCOUNT_JSON_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_JSON_KEY }} |