Build Android #39
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
name: Build Android | |
# Controls when the workflow will run | |
on: | |
workflow_call: | |
inputs: | |
build_environment: | |
description: "Build Environment" | |
type: string | |
required: true | |
upload_to_play_store: | |
description: "Upload to Play Store" | |
type: boolean | |
required: true | |
increment_version_number: | |
description: "Increment Version Number" | |
type: boolean | |
default: false | |
required: true | |
skip_slack_notification: | |
type: boolean | |
default: true | |
required: false | |
workflow_dispatch: | |
inputs: | |
build_environment: | |
description: "Build Environment" | |
type: choice | |
options: | |
- DEV | |
- TEST | |
- PROD | |
default: "development" | |
upload_to_play_store: | |
description: "Upload to Play Store" | |
type: boolean | |
default: false | |
increment_version_number: | |
description: "Increment Version Number" | |
type: boolean | |
default: false | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
build: | |
env: | |
ANGULAR_DIRECTORY: ./client/wfnews-war/src/main/angular | |
APP_CONFIG_FILE: ./client/wfnews-war/src/main/angular/src/assets/data/appConfig.mobile.json | |
API_KEY: ${{ inputs.build_environment == 'PROD' && secrets.WFNEWS_API_KEY_PROD || inputs.build_environment == 'TEST' && secrets.WFNEWS_API_KEY_TEST || secrets.WFNEWS_API_KEY_DEV }} | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ inputs.build_environment }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set short git commit SHA | |
id: vars | |
if: always() | |
run: | | |
calculatedSha=$(git rev-parse --short ${{ github.sha }}) | |
echo "::set-output name=short_sha::$calculatedSha" | |
- name: Add .npmrc file | |
working-directory: ${{ env.ANGULAR_DIRECTORY }} | |
env: | |
NPMRC: ${{ secrets.NPMRC }} | |
run: echo -e "$NPMRC" > .npmrc | |
- name: Add Google Services file | |
working-directory: "${{ env.ANGULAR_DIRECTORY }}/android/app" | |
env: | |
GOOGLE_FILE: ${{ vars.GOOGLE_SERVICES_JSON_BASE64 }} | |
run: | | |
echo "$GOOGLE_FILE" | base64 --decode --ignore-garbage > google-services.json | |
- name: Get XML Info | |
id: version | |
uses: mavrosxristoforos/[email protected] | |
with: | |
xml-file: "client/pom.xml" | |
xpath: "/*[local-name()='project']/*[local-name()='version']" | |
- name: Replace tokens | |
uses: cschleiden/[email protected] | |
with: | |
files: ${{ env.APP_CONFIG_FILE }} | |
env: | |
# From config.jsp | |
AGOL_ACTIVE_FIRES: https://services6.${{ vars.TARGET_ENV }}.bcwildfireservices.com${{ vars.AGOL_ACTIVE_FIRES }} | |
AGOL_AREA_RESTRICTIONS: ${{ vars.AGOL_AREA_RESTRICTIONS }} | |
AGOL_BANS_AND_PROHIBITIONS: ${{ vars.AGOL_BANS_AND_PROHIBITIONS }} | |
AGOL_DANGER_RATINGS: ${{ vars.AGOL_DANGER_RATINGS }} | |
AGOL_EVAC_ORDERS: ${{ vars.AGOL_EVAC_ORDERS }} | |
AGOL_FIRE_CENTRES: https://services6.${{ vars.TARGET_ENV }}.bcwildfireservices.com${{ vars.AGOL_FIRE_CENTRES }} | |
AGOL_PERIMETRES: https://services6.${{ vars.TARGET_ENV }}.bcwildfireservices.com${{ vars.AGOL_PERIMETRES }} | |
AGOL_URL: ${{ vars.AGOL_URL }} | |
APP_STORE_URL: ${{ vars.APP_STORE_URL }} | |
APPLICATION_ACRONYM: ${{ vars.APPLICATION_ACRONYM }} | |
APPLICATION_ENVIRONMENT: ${{ vars.DEFAULT_APPLICATION_ENVIRONMENT }} | |
BASE_URL: ${{ vars.BASE_URL }} | |
BC_WILDFIRE_RESPONSE_PAGE: ${{ vars.BC_WILDFIRE_RESPONSE_PAGE }} | |
BC_WILDFIRE_SUPPORT_PAGE: ${{ vars.BC_WILDFIRE_SUPPORT_PAGE }} | |
BUILD_NUMBER: ${{ github.run_number }} | |
BURN_REGISTRATION_LINE: ${{ vars.BURN_REGISTRATION_LINE }} | |
CONFIG_IM_URL: ${{ vars.WFIM_CLIENT_URL }} | |
DRIVEBC_BASE_URL: ${{ vars.DRIVEBC_BASE_URL }} | |
FACEBOOK_URL: ${{ vars.FACEBOOK_URL }} | |
GOOGLE_PLAY_URL: ${{ vars.GOOGLE_PLAY_URL }} | |
LAZY_AUTHENTICATE: ${{ vars.LAZY_AUTHENTICATE }} | |
# MAP_ICONS_ICON_ANCHOR: ${{ vars.MAP_ICONS_ICON_ANCHOR }} | |
# MAP_ICONS_ICON_SIZE: ${{ vars.MAP_ICONS_ICON_SIZE }} | |
# MAP_ICONS_SHADOW_SIZE: ${{ vars.MAP_ICONS_SHADOW_SIZE }} | |
# MAP_ICONS_TOOLTIP_OFFSET: ${{ vars.MAP_ICONS_TOOLTIP_OFFSET }} | |
MORE_INFORMATION_LINK: ${{ vars.MORE_INFORMATION_LINK }} | |
OPENMAPS_BASE_URL: https://maps.${{ vars.TARGET_ENV }}.bcwildfireservices.com | |
SERVICES6_BASE_URL: https://services6.${{ vars.TARGET_ENV }}.bcwildfireservices.com | |
POINT_ID_URL: ${{ vars.POINT_ID_URL }} | |
PROJECT_VERSION: ${{ steps.version.outputs.info }} | |
REPORT_A_WILDFIRE_PHONE_LINE: ${{ vars.REPORT_A_WILDFIRE_PHONE_LINE }} | |
SITEMINDER_URL_PREFIX: ${{ vars.SITEMINDER_URL_PREFIX }} | |
SYNC_INTERVAL_MINUTES: ${{ vars.SYNC_INTERVAL_MINUTES }} | |
TWITTER_URL: ${{ vars.TWITTER_URL }} | |
WEBADE_OAUTH2_AUTH_SCOPES: ${{ vars.WEBADE_OAUTH2_AUTH_SCOPES }} | |
WEBADE_OAUTH2_AUTHORIZE_URL: ${{ vars.WEBADE_OAUTH2_AUTHORIZE_URL }} | |
WEBADE_OAUTH2_CHECK_TOKEN_V2_URL: ${{ vars.WEBADE_OAUTH2_CHECK_TOKEN_URL }} | |
WEBADE_OAUTH2_CLIENT_ID: ${{ vars.WEBADE_OAUTH2_UI_CLIENT_ID }} | |
WEBADE_OAUTH2_ENABLE_CHECK_TOKEN: ${{ vars.WEBADE_OAUTH2_ENABLE_CHECK_TOKEN }} | |
WEBADE_OAUTH2_WFNEWS_REST_CLIENT_SECRET: ${{secrets.WEBADE_OAUTH2_WFNEWS_UI_CLIENT_SECRET}} | |
WFDM_API_URL: ${{ vars.WFDM_REST_URL }} | |
FIRE_REPORT_API_URL: ${{ vars.FIRE_REPORT_API_URL }} | |
NOTIFICATION_API_URL: ${{ vars.NOTIFICATION_API_URL }} | |
WFDM_PROXY: ${{ vars.WFDM_PROXY }} | |
WFIM_API_URL: ${{ vars.WFIM_CLIENT_URL }} | |
WFNEWS_API_KEY: ${{ secrets.API_KEY }} | |
WFNEWS_API_URL: ${{ vars.WFNEWS_API_URL }} | |
WILDFIRE_INFORMATION_LINE: ${{ vars.WILDFIRE_INFORMATION_LINE }} | |
ROF_PHONE_LINE: ${{ vars.ROF_PHONE_LINE }} | |
EVAC_DEFAULT_URL: ${{ vars.EVAC_DEFAULT_URL }} | |
CURRENT_RESTRICTIONS_URL: ${{ vars.CURRENT_RESTRICTIONS_URL }} | |
REC_SITE_TRAILS_CLOSURES_URL: ${{ vars.REC_SITE_TRAILS_CLOSURES_URL }} | |
PARKS_CLOSURES_URL: ${{ vars.PARKS_CLOSURES_URL }} | |
LOCAL_AUTHORITIES_URL: ${{ vars.LOCAL_AUTHORITIES_URL }} | |
WILDFIRE_PREPAREDNESS_URL: ${{ vars.WILDFIRE_PREPAREDNESS_URL }} | |
EMERGENCY_KIT_URL: ${{ vars.EMERGENCY_KIT_URL }} | |
PREPARED_BC_FACEBOOK: ${{ vars.PREPARED_BC_FACEBOOK }} | |
PREPARED_BC_TWITTER: ${{ vars.PREPARED_BC_TWITTER }} | |
PREPARED_BC_URL: ${{ vars.PREPARED_BC_URL }} | |
EMBC_URL: ${{ vars.EMBC_URL }} | |
EMBC_TWITTER: ${{ vars.EMBC_TWITTER }} | |
EVAC_GUIDANCE_URL: ${{ vars.EVAC_GUIDANCE_URL }} | |
LOCAL_GOV_URL: ${{ vars.LOCAL_GOV_URL }} | |
EMERGENCY_ALERT_URL: ${{ vars.EMERGENCY_ALERT_URL }} | |
DRIVE_BC_URL: ${{ vars.DRIVE_BC_URL}} | |
EVAC_SERVICES_URL: ${{ vars.EVAC_SERVICES_URL }} | |
YOUTUBE_API_KEY: ${{secrets.YOUTUBE_API_KEY}} | |
YOUTUBE_CHANNEL_ID: ${{secrets.YOUTUBE_CHANNEL_ID}} | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "17" | |
distribution: "adopt" | |
- name: Install Ionic | |
run: npm install -g @ionic/cli | |
- name: Install app dependencies | |
working-directory: ${{ env.ANGULAR_DIRECTORY }} | |
run: | | |
export NODE_OPTIONS="--max_old_space_size=4096" | |
npm cache clean --force | |
npm install --legacy-peer-deps | |
- name: Prepare app for build | |
working-directory: ${{ env.ANGULAR_DIRECTORY }} | |
run: ionic capacitor sync android --configuration=mobile | |
- name: Make gradlew executable | |
working-directory: ${{ env.ANGULAR_DIRECTORY }}/android | |
run: chmod +x ./gradlew | |
- name: Decode Service Account Key JSON File | |
uses: timheuer/base64-to-file@v1 | |
id: service_account_json_decode | |
with: | |
fileName: "serviceAccount.json" | |
encodedString: ${{ secrets.GOOGLE_PLAY_JSON_KEY }} | |
- name: Read serviceAccount.json | |
id: service_account_json_read | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: ${{ steps.service_account_json_decode.outputs.filePath }} | |
- uses: sparkfabrik/[email protected] | |
name: Build AAB and upload to Play Store | |
with: | |
build-type: "bundle" | |
gradle-task: "bundleRelease" | |
increment-build-number: ${{ inputs.increment_version_number }} | |
package-name: ${{ vars.PACKAGE_NAME }} | |
keystore-content: ${{ secrets.KEYSTORE_CONTENT }} | |
keystore-password: ${{ secrets.KEYSTORE_PASSWORD }} | |
keystore-alias: ${{ secrets.KEYSTORE_ALIAS }} | |
json-key-data: ${{ steps.service_account_json_read.outputs.content }} | |
upload-to-play-store: ${{ inputs.upload_to_play_store }} | |
project-path: "${{ env.ANGULAR_DIRECTORY }}/android/" | |
output-path: wfnews-release-${{ steps.vars.outputs.short_sha }}.aab | |
release-status: "completed" | |
ruby-version: "3.3" | |
- uses: actions/upload-artifact@v3 | |
name: Upload Build Artifact to GitHub | |
with: | |
name: wfnews-release-${{ steps.vars.outputs.short_sha }}.aab | |
path: "wfnews-release-${{ steps.vars.outputs.short_sha }}.aab" | |
retention-days: 3 | |
- name: Post to a Slack channel | |
id: slack | |
if: ('!cancelled()') && inputs.skip_slack_notification == false | |
uses: slackapi/[email protected] | |
env: | |
STATUS_EMOJI: ${{ job.status == 'success' && ':white_check_mark:' || ':x:' }} | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
with: | |
# Slack channel id, channel name, or user id to post message. | |
# See also: https://api.slack.com/methods/chat.postMessage#channels | |
# You can pass in multiple channels to post to by providing a comma-delimited list of channel IDs. | |
channel-id: "wildfire-build-notifier" | |
slack-message: | | |
:android: - ${{ steps.vars.outputs.short_sha }} : ${{ env.STATUS_EMOJI }} ${{ job.status }} | |
Workflow: ${{ github.workflow }} | |
Run number: ${{ github.run_number }} | |
Branch: ${{ github.ref_name }} | |
Environment: ${{ inputs.build_environment }} | |
Upload to Play Store: ${{ inputs.upload_to_play_store }} | |
Started by: ${{ github.triggering_actor }} |