-
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (82 loc) · 2.59 KB
/
ci.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: CI
on:
pull_request:
branches:
- main
paths-ignore:
- '**/*.md'
push:
branches:
- main
paths-ignore:
- '**/*.md'
env:
TERM: dumb
jobs:
assemble-and-check:
name: Build executable jar, run unit tests and static analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '22'
- uses: gradle/actions/setup-gradle@v4
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- run: ./gradlew assemble check
deploy:
name: Build and push container image to Google Artifact Registry, deploy to Cloud Run
# needs: [ assemble-and-check ]
# if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
CONTAINER_IMAGE: ${{ secrets.GCP_CONTAINER_IMAGE }}
REGION: ${{ secrets.GCP_REGION }}
SERVICE_NAME: ${{ secrets.GCP_SERVICE_NAME }}
CPU: 4
MEMORY: 2Gi
MIN_INSTANCES: 0
MAX_INSTANCES: 4
REQUEST_TIMEOUT: 30s
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
distribution: 'graalvm-community'
java-version: '22'
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: false # TODO remove
- name: Build GraalVM native executable
run: ./gradlew nativeCompile --no-configuration-cache
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGION }}-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCP_CREDENTIALS_JSON }}
- name: Build and push container image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.CONTAINER_IMAGE }}:latest
- uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }}
- uses: google-github-actions/setup-gcloud@v2
- name: Deploy to Cloud Run
run: |
gcloud run deploy ${{ env.SERVICE_NAME }} \
--image ${{ env.CONTAINER_IMAGE }}:latest \
--region ${{ env.REGION }} \
--cpu ${{ env.CPU }} \
--memory ${{ env.MEMORY }} \
--timeout ${{ env.REQUEST_TIMEOUT }} \
--min-instances ${{ env.MIN_INSTANCES }} \
--max-instances ${{ env.MAX_INSTANCES }} \
--platform managed \
--allow-unauthenticated