forked from akvelon/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (103 loc) · 4.8 KB
/
build_playground_backend.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
100
101
102
103
104
105
106
107
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Build And Deploy Playground Backend Application
on:
push:
tags: ['v*']
branches: ['master', 'release-*']
pull_request:
paths: ['playground/backend/**']
branches: ['playground-staging']
workflow_dispatch:
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
build_playground_backend_docker_image:
name: Build Playground Backend App
runs-on: [self-hosted, ubuntu-20.04]
env:
GO_VERSION: 1.19.3
BEAM_VERSION: 2.40.0
TERRAFORM_VERSION: 1.0.9
STAND_SUFFIX: ''
DATASTORE_EMULATOR_HOST: 127.0.0.1:8888
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Java
uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: '8'
- uses: actions/setup-go@v3
with:
go-version: '${{ env.GO_VERSION }}'
- name: Install dependencies
run: sudo apt update && sudo apt install libsnmp-dev -y
- name: Remove default github maven configuration
# This step is a workaround to avoid a decryption issue
run: rm ~/.m2/settings.xml
- name: Install sbt for running SCIO tests
run: |
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list &&\
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list &&\
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
sudo apt-get update && sudo apt-get install -y sbt
- name: Set up Cloud SDK and its components
uses: google-github-actions/setup-gcloud@v0
with:
install_components: 'beta,cloud-datastore-emulator'
version: '389.0.0'
- name: Run PreCommit
run: ./gradlew playground:backend:precommit
- name: install npm
uses: actions/setup-node@v3
with:
node-version: '14'
- name: install docker linter
run: npm install -g dockerlint
- name: lint dockerfile
run: dockerlint Dockerfile
working-directory: playground/backend/containers/java
- uses: hashicorp/setup-terraform@v1
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
if: startsWith(github.ref, 'refs/tags/')
- name: Set Docker Tag
run: echo "DOCKERTAG=${GITHUB_SHA}" >> $GITHUB_ENV
- name: Set Docker Tag If Github Tag was trigger
run: echo "DOCKERTAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/')
- name: Setup GCP account
run: |
echo "${{ secrets.GCP_PLAYGROUND_SA_KEY }}" | base64 -d > /tmp/gcp_access.json
if: startsWith(github.ref, 'refs/tags/')
- name: Login to Docker Registry
run: cat /tmp/gcp_access.json | docker login -u _json_key --password-stdin https://${{ secrets.PLAYGROUND_REGISTRY_NAME }}
if: startsWith(github.ref, 'refs/tags/')
- name: Deploy Backend Applications
env:
GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp_access.json
run: ./gradlew playground:terraform:deployBackend -Pdocker-tag=${{env.DOCKERTAG}} -Pproject_id=${{ secrets.GCP_PLAYGROUND_PROJECT_ID }} -Pproject_environment='beta' -Pdocker-repository-root='${{ secrets.PLAYGROUND_REGISTRY_NAME}}/${{ secrets.GCP_PLAYGROUND_PROJECT_ID }}/playground-repository'
if: startsWith(github.ref, 'refs/tags/')
- name: DB Index creation
run: |
gcloud auth activate-service-account --project=${{ secrets.GCP_PLAYGROUND_PROJECT_ID }} --key-file=/tmp/gcp_access.json
gcloud app deploy playground/index.yaml --project=${{ secrets.GCP_PLAYGROUND_PROJECT_ID }}
if: startsWith(github.ref, 'refs/tags/')
env:
GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp_access.json