Skip to content

Fix GA error

Fix GA error #85

Workflow file for this run

name: Build and Deploy API to Google Compute Engine
on:
push:
paths:
- 'api-service/**'
- '.github/workflows/api.yml'
branches:
- production
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
env:
IMAGE_TAG: ${{ vars.IMAGE_TAG }}
GCE_INSTANCE: ${{ vars.GCE_INSTANCE }}
GCE_INSTANCE_ZONE: ${{ vars.GCE_INSTANCE_ZONE }}
# TODO: Update - https://stackoverflow.com/questions/68244641/how-to-circumvent-compute-engines-downtime-during-container-deployments
jobs:
deploy:
name: Build and release
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Service Account
uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
- name: Configure Docker
run: gcloud --quiet auth configure-docker us-central1-docker.pkg.dev
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and Push
uses: docker/build-push-action@v3
with:
context: ./api-service
push: true
tags: ${{ env.IMAGE_TAG }}
cache-from: type=gha,scope=e2b-api
cache-to: type=gha,scope=e2b-api
- name: Delete old docker images from the instance
run: |-
gcloud compute instances add-metadata "$GCE_INSTANCE" \
--zone "$GCE_INSTANCE_ZONE" \
--metadata startup-script="#! /bin/bash
docker image prune -af"
- name: Update the server container
run: |-
gcloud compute instances update-container "$GCE_INSTANCE" \
--zone "$GCE_INSTANCE_ZONE" \
--container-image "$IMAGE_TAG"