-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: build and deploy docker image in ci
- Loading branch information
Showing
1 changed file
with
48 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,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 | ||