-
Notifications
You must be signed in to change notification settings - Fork 4
126 lines (107 loc) · 5.18 KB
/
main.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: CICD
on:
push:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
outputs:
docker-tag: ${{ steps.vars.outputs.sha_tag }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Cloud SDK auth
uses: google-github-actions/auth@v0.4.3
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Configure Google Cloud Docker repo authentication
run: gcloud auth configure-docker europe-west6-docker.pkg.dev --quiet
- name: Build with Maven
run: mvn -B clean verify
- name: Define var with Git commit sha ref
id: vars
run: echo "::set-output name=sha_tag::sha-$(git rev-parse --short HEAD)"
- name: Additionally tag Docker images with sha ref
if: github.ref == 'refs/heads/master'
run: mvn -B -Ddocker.image.tag=${{ steps.vars.outputs.sha_tag }} docker:tag
- name: Push all Docker images
if: github.ref == 'refs/heads/master'
run: |
docker image push --all-tags europe-west6-docker.pkg.dev/swiss-wowbagger/docker/mbrola
docker image push --all-tags europe-west6-docker.pkg.dev/swiss-wowbagger/docker/mbrola-jre
docker image push --all-tags europe-west6-docker.pkg.dev/swiss-wowbagger/docker/swiss-wowbagger-jdk-server
docker image push --all-tags europe-west6-docker.pkg.dev/swiss-wowbagger/docker/swiss-wowbagger-telegram
docker image push --all-tags europe-west6-docker.pkg.dev/swiss-wowbagger/docker/swiss-wowbagger-twitter
deploy-wowbagger:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- name: Cloud SDK auth
uses: google-github-actions/auth@v0.4.3
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Deploy to Cloud Run
run: >
gcloud run deploy swiss-wowbagger
--image europe-west6-docker.pkg.dev/swiss-wowbagger/docker/swiss-wowbagger-jdk-server:${{needs.build.outputs.docker-tag}}
--region europe-west6 --ingress=all --allow-unauthenticated
--set-secrets=AZURE_KEY=azure-key:latest
--cpu=2
--max-instances=1
--memory=256Mi
--args=-Xmx128m
--set-env-vars=JAVA_TOOL_OPTIONS="-XX:ActiveProcessorCount=2 -XX:MaxRAM=200m -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xss256k"
# Cloud Run First Generation instances don't support JVMs auto container mode detection thus we have to define settings manually
# --args=-Xmx128m is for GraalVM native images only while JAVA_TOOL_OPTIONS is for OpenJDK only
deploy-wowbagger-telegram:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- name: Cloud SDK auth
uses: google-github-actions/auth@v0.4.3
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Deploy to Cloud Run
run: >
gcloud run deploy swiss-wowbagger-telegram
--image europe-west6-docker.pkg.dev/swiss-wowbagger/docker/swiss-wowbagger-telegram:${{needs.build.outputs.docker-tag}}
--region europe-west6 --ingress=all --allow-unauthenticated
--set-secrets=TOKEN=stni-telegram-token:latest,USER=stni-telegram-user:latest
--cpu=2
--max-instances=1
--memory=256Mi
--args=-Xmx128m
--set-env-vars=JAVA_TOOL_OPTIONS="-XX:ActiveProcessorCount=2 -XX:MaxRAM=200m -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xss256k"
# Cloud Run First Generation instances don't support JVMs auto container mode detection thus we have to define settings manually
# --args=-Xmx128m is for GraalVM native images only while JAVA_TOOL_OPTIONS is for OpenJDK only
deploy-wowbagger-twitter:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- name: Cloud SDK auth
uses: google-github-actions/auth@v0.4.3
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Deploy to Cloud Run
run: >
gcloud run deploy swiss-wowbagger-twitter
--image europe-west6-docker.pkg.dev/swiss-wowbagger/docker/swiss-wowbagger-twitter:${{needs.build.outputs.docker-tag}}
--region europe-west6 --ingress=all --allow-unauthenticated
--set-secrets=CONSUMER_KEY=stni-twitter-consumer-key:latest,CONSUMER_SECRET=stni-twitter-consumer-secret:latest,ACCESS_TOKEN=stni-twitter-access-token:latest,ACCESS_SECRET=stni-twitter-access-secret:latest
--cpu=2
--max-instances=1
--memory=256Mi
--args=-Xmx128m
--set-env-vars=JAVA_TOOL_OPTIONS="-XX:ActiveProcessorCount=2 -XX:MaxRAM=200m -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xss256k"
# Cloud Run First Generation instances don't support JVMs auto container mode detection thus we have to define settings manually
# --args=-Xmx128m is for GraalVM native images only while JAVA_TOOL_OPTIONS is for OpenJDK only