Nightly Android builds #745
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: Nightly Android builds | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '39 20 * * 1-5' | |
jobs: | |
check_date: | |
runs-on: ubuntu-latest | |
name: Check latest commit | |
outputs: | |
should_run: ${{ steps.should_run.outputs.should_run }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: print latest_commit | |
run: echo ${{ github.sha }} | |
- id: should_run | |
continue-on-error: true | |
name: check latest commit is less than a day | |
if: ${{ github.event_name == 'schedule' }} | |
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false" | |
node-deb-gh-build-play: | |
runs-on: ubuntu-latest | |
needs: check_date | |
if: ${{ needs.check_date.outputs.should_run != 'false' }} | |
continue-on-error: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache node modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install jq | |
run: sudo apt-get install -y jq | |
- name: Declare some variables | |
shell: bash | |
run: | | |
echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV" | |
echo "app_version=$(jq -r '.version' app/package.json)" >> "$GITHUB_ENV" | |
- name: Create version string | |
shell: bash | |
run: | | |
echo "version_string=v${{env.app_version}}-android-#${{env.sha_short}}" >> "$GITHUB_ENV" | |
# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-java-with-gradle | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-java-with-gradle | |
- name: Set up adopt JDK 1.17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
# https://www.runway.team/blog/ci-cd-pipeline-android-app-fastlane-github-actions | |
# Because fastlane stuff is in android, we need working-directory | |
- name: Set up ruby env | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.3.1 | |
bundler-cache: true | |
working-directory: app/android | |
- name: Decode Service Account Key JSON File | |
uses: timheuer/base64-to-file@v1 | |
id: service_account_json_file | |
with: | |
fileName: "fastlane-android-google-play-key.json" | |
encodedString: ${{ secrets.GPLAY_SERVICE_ACCOUNT_KEY_JSON }} | |
- name: Decode Keystore File | |
uses: timheuer/base64-to-file@v1 | |
id: android_keystore | |
with: | |
fileName: "android-signing-keystore.jks" | |
encodedString: ${{ secrets.KEYSTORE_FILE }} | |
# https://github.com/android-actions/setup-android | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v3 | |
- name: Building webapp | |
run: | | |
export platform="github-actions-play" | |
export serverprefix="testing" | |
export VITE_CLUSTER_ADMIN_GROUP_NAME=cluster-admin | |
export VITE_COMMIT_VERSION=${{env.version_string}} | |
export VITE_SHOW_WIPE=true | |
export VITE_SHOW_MINIFAUXTON=true | |
export VITE_CONDUCTOR_URL=${{vars.NIGHTLY_CONDUCTOR_URL}} | |
export VITE_TAG=prodAndroid | |
export VITE_NOTEBOOK_LIST_TYPE=${{vars.NOTEBOOK_LIST_TYPE}} | |
export VITE_NOTEBOOK_NAME=${{vars.NOTEBOOK_NAME}} | |
export VITE_THEME=${{vars.THEME}} | |
export VITE_BUGSNAG_KEY=${{secrets.BUGSNAG_KEY}} | |
export VITE_APP_ID=${{vars.APP_ID}} | |
export VITE_APP_NAME="${{vars.APP_NAME}}" | |
export VITE_SHOW_RECORD_SUMMARY_COUNTS="${{vars.VITE_SHOW_RECORD_SUMMARY_COUNTS}}" | |
npm ci | |
npm run build | |
# https://capacitorjs.com/docs/android | |
# The bundle install shouldn't be necessary, but given we've got ios and android in... | |
- run: npm run app-update android --workspace=@faims3/app | |
- run: npm run webapp-sync --workspace=@faims3/app -- --deployment android | |
- name: Fastlane | |
run: | | |
cd app/android | |
bundle install | |
bundle exec fastlane deploy_fieldmark | |
env: | |
APP_ID: ${{ vars.APP_ID }} | |
ANDROID_RELEASE_STATUS: ${{ vars.ANDROID_RELEASE_STATUS }} | |
ANDROID_DEPLOY_TRACK: "internal" | |
JAVA_KEYSTORE: ${{ steps.android_keystore.outputs.filePath }} | |
JAVA_KEYSTORE_PASSWORD: ${{ secrets.JAVA_KEYSTORE_PASSWORD }} | |
JAVA_KEY: ${{ secrets.JAVA_KEY}} | |
JAVA_KEY_PASSWORD: ${{ secrets.JAVA_KEY_PASSWORD }} | |
ANDROID_JSON_KEY_FILE: ${{ steps.service_account_json_file.outputs.filePath }} | |
serverprefix: "testing" | |
prnum: ${{env.version_string}} |