-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (82 loc) · 3.16 KB
/
deployment-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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Deploy to GCP
on:
push:
branches: [ deployment-gcp-production, deployment-gcp-staging ]
workflow_dispatch:
inputs:
target:
description: 'Target'
required: true
default: 'production'
type: choice
options:
- 'staging'
- 'production'
env:
# TODO: Update with your Google Cloud project id. If you have changed the
# region and zone in your Terraform configuration, you will need to change
# it here too.
PROJECT: "<PROJECT ID>"
REGION: us-central1
ZONE: us-central1-c
jobs:
deploy:
name: Deploy to Google Cloud Run
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setting Target Mode from Input
if: ${{ github.event.inputs.target != '' }}
run: echo "TARGET=${{ github.event.inputs.target }}" >> $GITHUB_ENV
- name: Setting Target mode based on branch
if: ${{ github.event.inputs.target == '' }}
run: echo "TARGET=${GITHUB_REF##*-}" >> $GITHUB_ENV
- name: Set repository
run: echo "REPOSITORY=serverpod-${{ env.TARGET }}-container" >> $GITHUB_ENV
- name: Set Image Name
run: echo "IMAGE_NAME=serverpod" >> $GITHUB_ENV
- name: Set Service Name
run: echo "SERVICE_NAME=$(echo $IMAGE_NAME | sed 's/[^a-zA-Z0-9]/-/g')" >> $GITHUB_ENV
- name: Test
run: echo $SERVICE_NAME
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}"
- name: Create passwords file
working-directory: bluevsred_server
shell: bash
env:
SERVERPOD_PASSWORDS: ${{ secrets.SERVERPOD_PASSWORDS }}
run: |
pwd
echo "$SERVERPOD_PASSWORDS" > config/passwords.yaml
ls config/
- name: Configure Docker
working-directory: bluevsred_server
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
- name: Build the Docker image
working-directory: bluevsred_server
run: "docker build -t $IMAGE_NAME ."
- name: Tag the Docker image
working-directory: bluevsred_server
run: docker tag $IMAGE_NAME ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT }}/${{ env.REPOSITORY }}/$IMAGE_NAME
- name: Push Docker image
working-directory: bluevsred_server
run: docker push ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT }}/${{ env.REPOSITORY }}/$IMAGE_NAME
# Uncomment the following code to automatically restart the servers in the
# instance group when you push a new version of your code. Before doing
# this, make sure that you have successfully deployed a first version.
#
# - name: Restart servers in instance group
# run: |
# gcloud compute instance-groups managed rolling-action replace serverpod-${{ env.TARGET }}-group \
# --project=${{ env.PROJECT }} \
# --replacement-method='substitute' \
# --max-surge=1 \
# --max-unavailable=1 \
# --zone=${{ env.ZONE }}