Skip to content

Update default config #28

Update default config

Update default config #28

Workflow file for this run

name: CICD
on:
push:
branches: [ main ]
env:
GCLOUD_PROJECT: hemslo-chat-search
GCLOUD_REGION: us-west1
GCLOUD_REGISTRY: us-west1-docker.pkg.dev
GCLOUD_SERVICE: chat-search
GITHUB_REGISTRY: ghcr.io
OPENAI_API_KEY_SECRET_NAME: OPENAI_API_KEY
OPENAI_API_KEY_SECRET_VERSION: latest
REDIS_URL_SECRET_NAME: REDIS_URL
REDIS_URL_SECRET_VERSION: latest
AUTH_TOKEN_SECRET_NAME: AUTH_TOKEN
AUTH_TOKEN_SECRET_VERSION: latest
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: google-github-actions/auth@v2
id: gcloud_auth
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
token_format: access_token
- name: Login to Google Cloud Artifact Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GCLOUD_REGISTRY }}
username: oauth2accesstoken
password: ${{ steps.gcloud_auth.outputs.access_token }}
- name: Docker meta
uses: docker/metadata-action@v4
id: meta
with:
images: |
${{ env.GCLOUD_REGISTRY }}/${{ env.GCLOUD_PROJECT }}/${{ env.GCLOUD_SERVICE }}/${{ env.GCLOUD_SERVICE }}
${{ env.GITHUB_REGISTRY }}/${{ github.repository }}
tags: |
type=raw,value=latest
type=sha
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
outputs:
image: ${{ fromJSON(steps.meta.outputs.json).tags[1] }}
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: Create Service YAML
run: envsubst < ./service.template.yaml > service.yaml
env:
SERVICE: ${{ env.GCLOUD_SERVICE }}
IMAGE: ${{ needs.build.outputs.image }}
- name: Deploy to Cloud Run
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ env.GCLOUD_SERVICE }}
region: ${{ env.GCLOUD_REGION }}
metadata: service.yaml