Improve Deployment Setup (#119) #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This source file is part of the ENGAGE-HF based on the Stanford Spezi Template Application project | |
# | |
# SPDX-FileCopyrightText: 2023 Stanford University | |
# | |
# SPDX-License-Identifier: MIT | |
# | |
name: Deployment | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: | | |
The GitHub deployment environment. | |
required: true | |
default: 'development' | |
type: choice | |
options: | |
- development | |
- 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: deployment | |
cancel-in-progress: false | |
jobs: | |
determineenvironment: | |
name: Determine Environment | |
runs-on: ubuntu-latest | |
outputs: | |
environment: ${{ steps.determineenvironment.outputs.environment }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Determine Environment | |
id: determineenvironment | |
run: | | |
if [[ -z "${{ inputs.environment }}" ]]; then | |
echo "environment=staging" >> $GITHUB_OUTPUT | |
else | |
echo "environment=${{ inputs.environment }}" >> $GITHUB_OUTPUT | |
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 }} | |
provisioningProfileName: ${{ vars.PROVISIONING_PROFILE_NAME }} | |
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.1" | |
- run: | | |
echo "Injecting Environment Variables In Deployment Workflow ..." | |
echo "appidentifier: ${{ vars.APP_IDENTIFIER }}" | |
echo "provisioningProfileName: ${{ vars.PROVISIONING_PROFILE_NAME }}" | |
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 | |
buildandtest: | |
name: Build and Test | |
needs: determineenvironment | |
uses: ./.github/workflows/build-and-test.yml | |
permissions: | |
contents: read | |
secrets: inherit | |
iosapptestflightdeployment: | |
name: iOS App TestFlight Deployment | |
needs: [determineenvironment, vars, buildandtest] | |
uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 | |
permissions: | |
contents: read | |
with: | |
runsonlabels: '["macOS", "self-hosted"]' | |
environment: ${{ needs.determineenvironment.outputs.environment }} | |
googleserviceinfoplistpath: 'ENGAGEHF/Supporting Files/GoogleService-Info.plist' | |
setupsigning: true | |
fastlanelane: deploy environment:"${{ needs.determineenvironment.outputs.environment }}" appidentifier:"${{ needs.vars.outputs.appidentifier }}" provisioningProfile:"${{ needs.vars.outputs.provisioningProfileName }}" versionname:"${{ needs.vars.outputs.version }}" | |
secrets: inherit |