-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(release): implement web deploy to gcp
refs #345
- Loading branch information
1 parent
866a4cc
commit 44b5a5b
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
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
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 }}; |
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
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 }} |