update config file #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: staging | |
on: | |
push: | |
branches: | |
- master | |
- deploy/gcp | |
workflow_dispatch: | |
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@v2 | |
- name: Install (Buildx) | |
uses: docker/setup-buildx-action@v1 | |
- 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=sha | |
- name: Build | |
uses: docker/build-push-action@v2 | |
with: | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
context: . | |
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) | |
} | |
Microservice: | |
name: Deploy (Staging) | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
env: | |
namespace: cranecloud | |
image: cranecloud/monitoring-api | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# - uses: azure/k8s-set-context@v1 | |
# with: | |
# kubeconfig: ${{ secrets.RENU_KUBECONFIG}} | |
- name: Login (GCP) | |
uses: google-github-actions/auth@v0 | |
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/ | |
# monitoring-api ./helm/chart \ | |
- name: Helm Release | |
run: | | |
helm upgrade --install --create-namespace \ | |
monitoring-api cranecloud/cranecloud \ | |
--values helm/values.staging.yaml \ | |
--namespace $namespace \ | |
--set image.tag="${{ needs.build.outputs.tag }}" \ | |
--set environment.DATABASE_URI="${{ secrets.STAGING_DATABASE_URI }}" \ | |
--set environment.DATABASE_USER="${{ secrets.STAGING_DATABASE_USER }}" \ | |
--set environment.TEST_DATABASE_URL="${{ secrets.STAGING_TEST_DATABASE_URL }}" \ | |
--set environment.FLASK_APP_SALT="${{ secrets.STAGING_FLASK_APP_SALT }}" \ | |
--set environment.FLASK_APP_SECRET="${{ secrets.STAGING_FLASK_APP_SECRET }}" \ | |
--set environment.PRODUCT_BASE_URL="${{ secrets.STAGING_PRODUCT_BASE_URL }}" \ | |
--set environment.LOGGER_APP_URL="${{ secrets.STAGING_LOGGER_APP_URL }}" \ | |
--timeout=300s | |
- name: Monitor Rollout | |
run: | | |
kubectl rollout status deployment/monitoring-api --timeout=300s --namespace $namespace |