Skip to content

v2.28.1

v2.28.1 #53

Workflow file for this run

name: Build & Deploy
on:
release:
types: [published]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Login to Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build image
run: docker build -t ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_REF#refs/tags/v} .
- name: Publish image
run: docker push --all-tags ghcr.io/${GITHUB_REPOSITORY}
- name: Logout
run: docker logout ghcr.io
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
id-token: write
env:
NAMESPACE: production
DEPLOYMENT: rest-api-v2
CONTAINER: rest-api
steps:
- name: Check out
uses: actions/checkout@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: '${{ secrets.GC_WORKLOAD_IDENTITY_PROVIDER }}'
service_account: '${{ secrets.GC_SERVICE_ACCOUNT }}'
- name: Get GKE cluster credentials
uses: google-github-actions/get-gke-credentials@v2
with:
cluster_name: '${{ secrets.GC_GKE_CLUSTER_NAME }}'
location: '${{ secrets.GC_GKE_CLUSTER_LOCATION }}'
- name: Deploy image
run: kubectl -n ${NAMESPACE} set image deployment/${DEPLOYMENT} ${CONTAINER}=ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_REF#refs/tags/v}
- name: Check rollout
if: success()
run: kubectl -n ${NAMESPACE} rollout status deployment/${DEPLOYMENT} -w --timeout=5m
- name: Roll back
if: failure()
run: kubectl -n ${NAMESPACE} rollout undo deployment/${DEPLOYMENT}