-
-
Notifications
You must be signed in to change notification settings - Fork 2
134 lines (130 loc) · 4.34 KB
/
deployment.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
127
128
129
130
131
132
133
134
#
# This source file is part of the Stanford Spezi open-source project
#
# SPDX-FileCopyrightText: 2024 Stanford University
#
# SPDX-License-Identifier: MIT
#
name: Deployment
on:
push:
branches:
- main
workflow_dispatch:
inputs:
environment:
description: |
The GitHub deployment environment.
required: true
default: 'internal'
type: choice
options:
- internal
- staging
- production
version:
description: |
The semantic version of the app that should be released.
required: true
type: string
workflow_call:
inputs:
environment:
description: |
The GitHub deployment environment.
required: false
type: string
default: staging
version:
description: |
The semantic version of the app that should be released.
required: true
type: string
concurrency:
group: main
cancel-in-progress: false
jobs:
determineenvironment:
name: Determine Environment
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.determineenvironment.outputs.environment }}
steps:
- name: Determine Environment
id: determineenvironment
run: |
echo "Determining the Environment ..."
if [[ -z "${{ inputs.environment }}" ]]; then
echo "environment=staging" >> $GITHUB_OUTPUT
echo "environment: staging"
else
echo "environment=${{ inputs.environment }}" >> $GITHUB_OUTPUT
echo "environment: ${{ inputs.environment }}"
fi
vars:
name: Inject Environment Variables In Deployment Workflow
needs: determineenvironment
runs-on: ubuntu-latest
environment: ${{ needs.determineenvironment.outputs.environment }}
outputs:
appidentifier: ${{ vars.APP_IDENTIFIER }}
version: ${{ steps.vars.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
with:
semver_only: true
initial_version: "2.0.0"
- run: |
echo "Injecting Environment Variables In Deployment Workflow ..."
echo "appidentifier: ${{ vars.APP_IDENTIFIER }}"
if [[ -z "${{ inputs.version }}" ]]; then
echo "version=${{ steps.get-latest-tag.outputs.tag }}" >> $GITHUB_OUTPUT
echo "version: ${{ steps.get-latest-tag.outputs.tag }}"
else
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
echo "version: ${{ inputs.version }}"
fi
buildtestandanalyze:
uses: ./.github/workflows/build-test-analyze.yml
secrets: inherit
googleplayinternal:
name: Upload App to Google Play
runs-on: ubuntu-latest
needs: [buildtestandanalyze, determineenvironment, vars]
environment: ${{ needs.determineenvironment.outputs.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- name: Decode and Write Google Service JSON
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: echo $GOOGLE_SERVICES_JSON | base64 --decode >./app/google-services.json
- name: Decode and Write Secrets
env:
SECRETS_XML: ${{ secrets.SECRETS_XML }}
run: echo $SECRETS_XML | base64 --decode >./modules/account/src/main/res/values/secrets.xml
- name: Setup keystore file
env:
KEY_STORE: ${{ secrets.KEY_STORE }}
run: |
echo $KEY_STORE | base64 -d > keystore.jks
echo $KEY_STORE | base64 -d > app/keystore.jks
- name: Build and Deploy
env:
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
SERVICE_ACCOUNT_JSON_KEY: ${{ secrets.SERVICE_ACCOUNT_JSON_KEY }}
run: bundle exec fastlane internal environment:"${{ needs.determineenvironment.outputs.environment }}" applicationid:"${{ needs.vars.outputs.appidentifier }}" versionname:"${{ needs.vars.outputs.version }}"