Skip to content

Commit

Permalink
Merge pull request #1762 from Logflare/chore/update-versioned-staging…
Browse files Browse the repository at this point in the history
…-deploy

chore: update staging deploy scripts
  • Loading branch information
Ziinc authored Oct 17, 2023
2 parents 218b42b + 59ff159 commit 3e00972
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 44 deletions.
31 changes: 4 additions & 27 deletions .github/workflows/trigger-cloudbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,9 @@ jobs:
version: "449.0.0"
project_id: ${{ env.project_id }}
- name: Build & deploy for staging (main branch)
if: github.event_name != 'release' && matrix.env == 'staging'
if: github.event_name == 'push' && matrix.env == 'staging'
run: make deploy.staging.main

# - name: Bake image for versioned (prod and staging)
# if: github.event_name == 'release'
# run: |
# gcloud builds submit \
# projects/${{ env.project_id }}/locations/${{ env.region }}/connections/${{ env.host_connection}}/repositories/${{ env.repository_name }} \
# --config=cloudbuild/${{ matrix.env }}/build-image.yaml \
# --substitutions=_IMAGE_TAG=${{ env.version }} \
# --region=${{ env.region }}

# only do auto-deploy for staging non-versioned
# deploy:
# runs-on: ubuntu-latest
# needs:
# - build_image
# if: github.ref == 'refs/heads/main' && github.event_name == 'pull_request'
# name: Deploy to Staging
# steps:
# - name: Env vars
# run: |
# echo "short_sha=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
# - name: Deploy
# run: |
# gcloud builds submit \
# --no-source \
# --config=cloudbuild/staging/deploy.yaml \
# --substitutions=_IMAGE_TAG=dev-${{ env.short_sha }}
- name: Build & ${{ matrix.env == 'prod' && 'pre-deploy' || 'deploy'}} for ${{ matrix.env }} (versioned)
if: (github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: make deploy.${{ matrix.env }}.versioned
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ERL_COOKIE ?= monster
ENV ?= dev
SHA_IMAGE_TAG ?= dev-$(shell git rev-parse --short HEAD)
VERSION ?= $(shell cat ./VERSION)
NORMALIZED_VERSION ?= $(shell cat ./VERSION | tr '.' '-')

help:
@cat DEVELOPMENT.md
Expand Down Expand Up @@ -142,8 +143,19 @@ deploy.staging.versioned:
gcloud builds submit \
--no-source \
--config=./cloudbuild/staging/deploy.yaml \
--substitutions=_IMAGE_TAG=$(VERSION),_INSTANCE_TYPE=c2d-standard-8,_CLUSTER=versioned \
--substitutions=_IMAGE_TAG=$(VERSION),_NORMALIZED_IMAGE_TAG=$(NORMALIZED_VERSION),_INSTANCE_TYPE=c2d-standard-2,_CLUSTER=versioned \
--region=us-central1 \
--gcs-log-dir="gs://logflare-staging_cloudbuild-logs/logs"


deploy.prod.versioned:
gcloud builds submit \
projects/logflare-staging/locations/us-central1/connections/github-logflare/repositories/Logflare-logflare \
--revision=main \
--config=cloudbuild/staging/build-image.yaml \
--substitutions=_IMAGE_TAG=$(VERSION) \
--region=us-central1 \
--gcs-log-dir="gs://logflare-staging_cloudbuild-logs/logs"


.PHONY: deploy.staging.main
32 changes: 16 additions & 16 deletions cloudbuild/staging/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ steps:
- --tags=phoenix-http,https-server
- --container-image=${_CONTAINER_IMAGE}
- --container-privileged
- --container-restart-policy=always
- --container-env=LOGFLARE_GRPC_PORT=4001,LOGFLARE_MIN_CLUSTER_SIZE=1,OVERRIDE_MAGIC_COOKIE=${_COOKIE}
- --create-disk=auto-delete=yes,device-name=logflare-staging-cluster-privileged-e2-cos-89-shutdown-12,image=projects/cos-cloud/global/images/cos-stable-105-17412-156-59,mode=rw,size=100,type=pd-ssd
- --no-shielded-secure-boot
- --shielded-vtpm
- --shielded-integrity-monitoring
- --container-restart-policy=always
- --container-env=LOGFLARE_GRPC_PORT=4001,LOGFLARE_MIN_CLUSTER_SIZE=1,OVERRIDE_MAGIC_COOKIE=${_COOKIE}
- --create-disk=auto-delete=yes,device-name=logflare-staging-cluster-privileged-e2-cos-89-shutdown-12,image=projects/cos-cloud/global/images/cos-stable-105-17412-156-59,mode=rw,size=100,type=pd-ssd
- --no-shielded-secure-boot
- --shielded-vtpm
- --shielded-integrity-monitoring
- --labels=container-vm=cos-stable-105-17412-156-59
# update instance group to the new template
- name: gcr.io/cloud-builders/gcloud
Expand All @@ -44,16 +44,16 @@ steps:
- --replacement-method=substitute
- --version=template=projects/logflare-staging/global/instanceTemplates/${_TEMPLATE_NAME}


substitutions:
_COOKIE: default
_CLUSTER: main
_INSTANCE_TYPE: e2-standard-2
_INSTANCE_GROUP: instance-group-staging-${_CLUSTER}
_IMAGE_TAG: $SHORT_SHA
_TEMPLATE_NAME: logflare-staging-${_CLUSTER}-cluster-${_IMAGE_TAG}
_CONTAINER_IMAGE: gcr.io/logflare-staging/logflare_app:${_IMAGE_TAG}
_COOKIE: default
_CLUSTER: main
_NORMALIZED_IMAGE_TAG: ${_IMAGE_TAG}
_INSTANCE_TYPE: e2-standard-2
_INSTANCE_GROUP: instance-group-staging-${_CLUSTER}
_IMAGE_TAG: $SHORT_SHA
_TEMPLATE_NAME: logflare-staging-${_CLUSTER}-cluster-${_NORMALIZED_IMAGE_TAG}
_CONTAINER_IMAGE: gcr.io/logflare-staging/logflare_app:${_IMAGE_TAG}
timeout: 1800s
options:
dynamicSubstitutions: true
substitutionOption: 'ALLOW_LOOSE'
dynamicSubstitutions: true
substitutionOption: "ALLOW_LOOSE"

0 comments on commit 3e00972

Please sign in to comment.