Skip to content

Commit

Permalink
ci(release): implement web deploy to gcp
Browse files Browse the repository at this point in the history
refs #345
  • Loading branch information
ygrishajev committed Oct 17, 2024
1 parent 866a4cc commit 44b5a5b
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/actions/gcp-deploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Update GCP VM instance container image

inputs:
instance-name:
description: 'VM instance name'
required: true
image:
description: 'Docker image tag'
required: true
credentials_json:
description: 'Service account credentials JSON'
required: true


runs:
using: "composite"
steps:
- name: 'Authenticate with Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ inputs.credentials_json }}

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
version: '>= 363.0.0'

- name: Update image
shell: bash
run: |
gcloud compute instances update-container ${{ inputs.instance-name }} \
--container-image=${{ inputs.image }};
62 changes: 62 additions & 0 deletions .github/workflows/deploy-web-to-gcp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Deploy Console Web to GCP

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to deploy'
required: true
type: string

concurrency:
group: ${{ github.workflow }}

jobs:
deploy:
name: Define Variables
runs-on: ubuntu-latest

steps:
- uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
version: '>= 363.0.0'

- name: Define variables
id: vars
env:
PROD_WEB_INSTANCE_NAME: ${{ vars.PROD_WEB_INSTANCE_NAME }}
BETA_WEB_INSTANCE_NAME: ${{ vars.BETA_WEB_INSTANCE_NAME }}
run: |
tag="${{ github.event.inputs.tag }}"
version="${tag#*/}"
if [[ "$version" == *"-"* ]]; then
prerelease_type=$(echo "$version" | cut -d'-' -f2 | cut -d'.' -f1)
else
prerelease_type="prod"
fi
image="${{ vars.WEB_REGISTRY }}:$version"
echo "prerelease_type=${prerelease_type}"
upper_prerelease_type=$(echo "$prerelease_type" | tr '[:lower:]' '[:upper:]')
instance_var_name="${upper_prerelease_type}_WEB_INSTANCE_NAME"
instance_name="${!instance_var_name}"
echo "image=${image}"
echo "instance-name=${instance_name}"
echo "image=${image}" >> "$GITHUB_OUTPUT"
echo "instance-name=${instance_name}" >> "$GITHUB_OUTPUT"
- name: Deploy
uses: ./github/actions/gcp-deploy
with:
instance-name: ${{ steps.vars.outputs.instance-name }}
image: ${{ steps.vars.outputs.image }}
credentials_json: ${{ secrets.GCP_SA_KEY }}

0 comments on commit 44b5a5b

Please sign in to comment.