-
Notifications
You must be signed in to change notification settings - Fork 59
77 lines (62 loc) · 2.38 KB
/
deploy-web-to-gcp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Deploy Console Web to GCP
on:
workflow_dispatch:
inputs:
tag:
description: "Tag to deploy"
required: true
type: string
workflow_call:
inputs:
tag:
description: "Tag to deploy"
required: true
type: string
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}
jobs:
deploy:
name: Deploy to GCP
runs-on: ubuntu-latest
environment: ${{ contains(github.event.inputs.tag, '-beta') && 'beta' || 'production' }}
steps:
- name: Define variables
id: vars
run: |
tag="${{ github.event.inputs.tag }}"
if [[ ! "$tag" =~ ^console-web/v[0-9]+\.[0-9]+\.[0-9]+(-beta)?$ ]]; then
echo "::error::Invalid tag format. Expected console-web/v* or console-web/v*-beta (e.g., console-web/v1.2.3 or console-web/v1.2.3-beta)"
exit 1
fi
version="${tag#*/v}"
instance_name=""
if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+-beta$ ]]; then
instance_name="${{ vars.BETA_WEB_INSTANCE_NAME }}"
elif [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
instance_name="${{ vars.PROD_WEB_INSTANCE_NAME }}"
fi
image="${{ vars.WEB_REGISTRY }}:$version"
echo "instance-name=${instance_name}"
echo "image=${image}"
echo "instance-name=${instance_name}" >> "$GITHUB_OUTPUT"
echo "image=${image}" >> "$GITHUB_OUTPUT"
- name: Checkout repository
if: steps.vars.outputs.instance-name != '' && steps.vars.outputs.image != ''
uses: actions/checkout@v4
- name: Deploy
if: steps.vars.outputs.instance-name != '' && steps.vars.outputs.image != ''
uses: ./.github/actions/gcp-deploy
with:
instance-name: ${{ steps.vars.outputs.instance-name }}
image: ${{ steps.vars.outputs.image }}
credentials_json: ${{ secrets.GCP_SA_KEY }}
zone: ${{ vars.GCP_ZONE }}
- name: Post Deploy Summary
if: success()
run: |
echo "## Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "✅ Successfully deployed version ${{ github.event.inputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- Instance: ${{ steps.vars.outputs.instance-name }}" >> $GITHUB_STEP_SUMMARY
echo "- Image: ${{ steps.vars.outputs.image }}" >> $GITHUB_STEP_SUMMARY