Skip to content

fix: build and deploy docker image in ci #1

fix: build and deploy docker image in ci

fix: build and deploy docker image in ci #1

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