Skip to content

test deployment

test deployment #7

Workflow file for this run

---
name: Prod
on:
push:
branches:
- ch-update-deployments
release:
types:
- released
- prereleased
jobs:
build:
outputs:
image: ${{ steps.export.outputs.image }}
tag: ${{ steps.export.outputs.tag }}
runs-on: ubuntu-latest
env:
image: cranecloud/monitoring-api
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: master # Reference branch
- name: Install (Buildx)
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: meta
name: Tag
uses: docker/metadata-action@v3
with:
flavor: |
latest=true
images: ${{ env.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Build
uses: docker/build-push-action@v2
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: docker/prod/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}
- id: export
name: Export
uses: actions/github-script@v5
with:
script: |
const metadata = JSON.parse(`${{ steps.meta.outputs.json }}`)
const fullUrl = metadata.tags.find((t) => t.includes(':sha-'))
if (fullUrl == null) {
core.error('Unable to find sha tag of image')
} else {
const tag = fullUrl.split(':')[1]
core.setOutput('image', fullUrl)
core.setOutput('tag', tag)
}
Production:
name: Deploy (Production)
needs:
- build
runs-on: ubuntu-latest
env:
namespace: cranecloud-prod
steps:
- name: Clone
uses: actions/checkout@v2
- name: Login (GCP)
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.CREDENTIALS_JSON }}
- name: Install (Gcloud)
uses: google-github-actions/setup-gcloud@v1
with:
project_id: crane-cloud-274413
install_components: "gke-gcloud-auth-plugin"
- name: Login (Kubernetes Cluster)
uses: google-github-actions/get-gke-credentials@v1
with:
cluster_name: staging-cluster
location: us-central1-a
project_id: crane-cloud-274413
- name: Add Repo (cranecloud)
run: |
helm repo add cranecloud https://crane-cloud.github.io/helm-charts/
- name: Helm Release
run: |
helm upgrade --install \
monitoring-api cranecloud/cranecloud \
--values helm/values.prod.yaml \
--namespace $namespace \
--set image.tag="${{ needs.build.outputs.tag }}" \
--set environment.DATABASE_URI="${{ secrets.PRODUCTION_DATABASE_URI }}" \
--set environment.DATABASE_USER="${{ secrets.PRODUCTION_DATABASE_USER }}" \
--set environment.TEST_DATABASE_URL="${{ secrets.PRODUCTION_TEST_DATABASE_URL }}" \
--set environment.FLASK_APP_SALT="${{ secrets.PRODUCTION_JWT_SALT }}" \
--set environment.FLASK_APP_SECRET="${{ secrets.PRODUCTION_JWT_SALT }}" \
--set environment.PRODUCT_BASE_URL="${{ secrets.PRODUCTION_PRODUCT_BASE_URL }}" \
--set environment.LOGGER_APP_URL="${{ secrets.PRODUCTION_LOGGER_APP_URL }}" \
--timeout=300s
- name: Monitor Rollout
run: |
kubectl rollout status deployment/monitoring-api --timeout=300s --namespace $namespace