Skip to content

Commit

Permalink
Feature/build push image workflow (#16)
Browse files Browse the repository at this point in the history
* Add Workflow for building and pushing images to GAR with a self hosted runner
  • Loading branch information
shub-kris authored Feb 20, 2024
1 parent 1963e1b commit 882a1dd
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build-push-image.yml
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


15 changes: 15 additions & 0 deletions .github/workflows/test-build-push-image.yml
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 }}

0 comments on commit 882a1dd

Please sign in to comment.