Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Work in progress

Work in progress #162

Workflow file for this run

name: Deploy on Google Cloud Platform
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Up Go
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Run Lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run ./...
# - name: Run NilAway
# run: |
# go install go.uber.org/nilaway/cmd/nilaway@latest
# nilaway ./...
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Authenticate Docker
run: gcloud auth configure-docker --quiet ${{ secrets.REGION }}-docker.pkg.dev
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ secrets.REGISTRY }}/${{ secrets.SERVICE_NAME }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy to Cloud Run
env:
SERVICE_NAME: ${{ secrets.SERVICE_NAME }}
REGION: ${{ secrets.REGION }}
REGISTRY: ${{ secrets.REGISTRY }}
GITHUB_SHA: ${{ github.sha }}
run: |
cat <<EOF | envsubst > service.yaml
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: "$SERVICE_NAME"
labels:
cloud.googleapis.com/location: "$REGION"
spec:
template:
metadata:
annotations:
run.googleapis.com/execution-environment: "gen2"
run.googleapis.com/startup-cpu-boost: "true"
autoscaling.knative.dev/maxScale: "16"
spec:
containerConcurrency: "120"
timeoutSeconds: "60"
containers:
- image: "$REGISTRY/$SERVICE_NAME:$GITHUB_SHA"
name: "play"
resources:
limits:
cpu: "4000m"
memory: "8Gi"
EOF
gcloud run services replace service.yaml