-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (87 loc) · 3.82 KB
/
deploy-faas.yml
File metadata and controls
98 lines (87 loc) · 3.82 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
name: Deploy Cloud Functions
on:
workflow_call:
inputs:
module_name:
required: true
type: string
faas_name:
required: true
type: string
java_version:
type: string
default: 17
secrets:
gh_packages_read_access_token:
required: true
gh_deployment_creation_access_token:
required: true
extra_gradle_parameters:
required: false
env:
faas_location: ${{ inputs.module_name }}-faas
final_name: ${{ inputs.module_name }}-faas-${{ inputs.faas_name }}
jobs:
publish_and_deploy:
permissions:
contents: read
id-token: write
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 cache
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/**') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ inputs.java_version }}
- name: Get docker tag and deployment env
id: get_context
run: |
ENV=$([ '${{ github.ref }}' == 'refs/heads/master' ] && echo 'dev' || echo 'prod' )
VERSION=$([ $ENV == 'dev' ] && 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.faas_location }}:${{ env.final_name }}:currentVersion | tail -n1 )
echo "env=$ENV" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "bucket_prefix=$([ $ENV == 'dev' ] && echo 'xo-dev' || echo 'xo')" >> $GITHUB_OUTPUT
echo "google_project_id=$([ $ENV == 'prod' ] && echo '227734476075' || echo '183854350784')" >> $GITHUB_OUTPUT
echo "google_project_name=$([ $ENV == 'prod' ] && echo 'attraqt-xo' || echo 'attraqt-xo-dev')" >> $GITHUB_OUTPUT
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
token_format: access_token
workload_identity_provider: projects/${{ steps.get_context.outputs.google_project_id }}/locations/global/workloadIdentityPools/github/providers/github-actions
service_account: ga-publisher@${{ steps.get_context.outputs.google_project_name }}.iam.gserviceaccount.com
- name: Build Zip fat jar
run: >
./gradlew :${{ env.faas_location }}:${{ env.final_name }}:zipFatJar
-Pgpr.read.user=${{ inputs.module_name }}
-Pgpr.read.key=${{ secrets.gh_packages_read_access_token }}
-ParchiveVersion=${{ steps.get_context.outputs.version }}
${{ secrets.extra_gradle_parameters }}
- name: Rename zip
run: >
mv ./${{ env.faas_location }}/${{ env.final_name }}/build/distributions/${{ env.final_name }}-${{ steps.get_context.outputs.version }}.zip
./${{ steps.get_context.outputs.version }}.zip
- name: Upload Zip Jar
uses: 'google-github-actions/upload-cloud-storage@v1'
with:
path: './${{ steps.get_context.outputs.version }}.zip'
destination: '${{ steps.get_context.outputs.bucket_prefix }}-cloud-functions/${{ env.final_name }}'
gzip: false
- 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>>