Skip to content

Commit

Permalink
fix: build and deploy docker image in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbpvsc committed Sep 8, 2024
1 parent 3a247aa commit a6266dd
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/docker-build-gcp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Push Docker Image to GCP Artifact Registry

# Trigger the workflow only when a git tag following SemVer is pushed
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3

# Set up Google Cloud authentication
- name: Set up GCP authentication
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}'

# Configure Docker to use gcloud as a credential helper
- name: Configure Docker for Google Artifact Registry
run: |
gcloud auth configure-docker us-east1-docker.pkg.dev
# Extract version tag without the 'v' prefix
- name: Extract version without 'v' prefix
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

# Build the Docker image using the version without the 'v' and tag it as 'latest' as well
- name: Build Docker image
run: |
docker build -t us-east1-docker.pkg.dev/marginfi-dev/main/eva01:${{ env.VERSION }} \
-t us-east1-docker.pkg.dev/marginfi-dev/main/eva01:latest .
# Push the Docker image to Artifact Registry with the version tag
- name: Push Docker image with version tag to Artifact Registry
run: |
docker push us-east1-docker.pkg.dev/marginfi-dev/main/eva01:${{ env.VERSION }}
# Push the Docker image to Artifact Registry with the 'latest' tag
- name: Push Docker image with 'latest' tag to Artifact Registry
run: |
docker push us-east1-docker.pkg.dev/marginfi-dev/main/eva01:latest

0 comments on commit a6266dd

Please sign in to comment.