-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (96 loc) · 4.22 KB
/
deploy-grpc.yml
File metadata and controls
109 lines (96 loc) · 4.22 KB
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
name: Deploy gRPC service
on:
workflow_call:
inputs:
module_name:
required: true
type: string
service_name:
required: true
type: string
java_version:
type: string
default: 11
legacy_docker_build_push:
type: string
default: 'false'
secrets:
GCP_PUBLISHER_SERVICE_ACCOUNT_KEY:
required: true
GH_PACKAGES_READ_ACCESS_TOKEN:
required: true
GH_DEPLOYMENT_CREATION_ACCESS_TOKEN:
required: true
ARTIFACTORY_USER:
required: false
ARTIFACTORY_PASSWORD:
required: false
env:
final_name: ${{ inputs.module_name }}-${{ inputs.service_name }}
artifactory_password: ${{ secrets.ARTIFACTORY_PASSWORD }}
jobs:
publish_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Fetch tag history
run: git fetch --prune --unshallow
if: github.ref == 'refs/heads/master'
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ inputs.java_version }}
cache: 'gradle'
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_PUBLISHER_SERVICE_ACCOUNT_KEY }}
create_credentials_file: true
export_environment_variables: true
- name: Install Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Configure docker authentication
run: gcloud auth configure-docker
- name: Get docker tag and deployment env
id: get_context
run: |
VERSION=$([ '${{ github.ref }}' == 'refs/heads/master' ] && git rev-parse --short HEAD || ./gradlew --quiet --console=plain -Prelease.quiet -Pgpr.read.user=${{ inputs.module_name }} -Pgpr.read.key=${{ secrets.GH_PACKAGES_READ_ACCESS_TOKEN }} ${{ env.final_name }}:currentVersion | tail -n1 )
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "image_name=eu.gcr.io/attraqt-xo/${{ env.final_name }}:$VERSION" >> $GITHUB_OUTPUT
echo "env=$([ '${{ github.ref }}' == 'refs/heads/master' ] && echo 'dev' || echo 'prod')" >> $GITHUB_OUTPUT
- name: Build Docker image
run: ./gradlew -Pgpr.read.user=${{ inputs.module_name }} -Pgpr.read.key=${{ secrets.GH_PACKAGES_READ_ACCESS_TOKEN }} ${{ env.final_name }}:bootBuildImage --imageName=${{ steps.get_context.outputs.image_name }}
if: ${{ inputs.legacy_docker_build_push != 'true' && env.artifactory_password == null }}
- name: Build Docker image
run: >
./gradlew
-Pgpr.read.user=${{ inputs.module_name }}
-Pgpr.read.key=${{ secrets.GH_PACKAGES_READ_ACCESS_TOKEN }}
-Partifactory.user=${{ secrets.ARTIFACTORY_USER }}
-Partifactory.password=${{ secrets.ARTIFACTORY_PASSWORD }}
${{ env.final_name }}:bootBuildImage
--imageName=${{ steps.get_context.outputs.image_name }}
if: ${{ inputs.legacy_docker_build_push != 'true' && env.artifactory_password != null }}
- name: Push Docker image
run: docker push ${{ steps.get_context.outputs.image_name }}
if: ${{ inputs.legacy_docker_build_push != 'true' }}
- name: Build & Push Docker image (using gradle plugin)
run: |
./gradlew \
-Pgpr.read.user=${{ inputs.module_name }} \
-Pgpr.read.key=${{ secrets.GH_PACKAGES_READ_ACCESS_TOKEN }} \
-Partifactory.user=${{ secrets.ARTIFACTORY_USER }} \
-Partifactory.password=${{ secrets.ARTIFACTORY_PASSWORD }} \
-Pdocker.tag=${{ steps.get_context.outputs.version }} \
:${{ env.final_name }}:dockerPushImage --console=plain
if: ${{ inputs.legacy_docker_build_push == 'true' }}
- name: Deploy
uses: Attraqt/github_actions/.github/actions/deploy@main
with:
repo: xo-terragrunt-${{ steps.get_context.outputs.env }}
ref: master
environment: ${{ steps.get_context.outputs.env }}
token: ${{ secrets.GH_DEPLOYMENT_CREATION_ACCESS_TOKEN }}
task: ${{ env.final_name }}:${{ steps.get_context.outputs.version }}
required_contexts: <<EMPTY>>