Shivam | Refactor Action Workflows (#5103)

* make generate_apk.yml reusable

* make generate_apk.yml reusable

* make generate_apk.yml reusable

* stringify environment and type

* temp echo

* remove defaults

* remove defaults

* remove defaults

* change inputs

* add generate_apk input fallbacks

* remove echo

* check operator precedence

* revert test

* remove redundant quotes

* add back quotes

* add matrix strategy

* make matrix 1D

* fix array

* revert array

* build bot dev and qa debug

* update change conditions

* add release builds

* temp

* temp

* revert temp

* update qa release
This commit is contained in:
Shivam Goyal
2023-01-30 20:13:21 +05:30
committed by GitHub Enterprise
parent e095dd3ee5
commit ba87ad227e
2 changed files with 39 additions and 40 deletions

View File

@@ -5,40 +5,31 @@ on:
branches: [ master, release-*, development ]
pull_request:
branches: [ master, release-*, development ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: [ self-hosted, android ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: adopt
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Assemble with Stacktrace - QA Debug
run: ./gradlew assembleQaDebug --stacktrace
- name: Upload APK as Artifact
uses: actions/upload-artifact@v3
with:
name: app-qa-debug
path: app/build/outputs/apk/qa/debug/
retention-days: 30
- name: Distribute APK via Firebase
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: synced-actions/Firebase-Distribution-Github-Action@v1
with:
appId: ${{ secrets.FIREBASE_QA_APP_ID }}
serviceCredentialsFileContent: ${{ secrets.DISTRIBUTION_CREDENTIAL_FILE_CONTENT }}
groups: android-testers
file: app/build/outputs/apk/qa/debug/app-qa-debug.apk
build-qa-debug:
uses: ./.github/workflows/generate_apk.yml
with:
environment: qa
type: debug
build-dev-debug:
uses: ./.github/workflows/generate_apk.yml
with:
environment: dev
type: debug
build-qa-release:
if: github.event_name == 'push' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release-'))
uses: ./.github/workflows/generate_apk.yml
with:
environment: qa
type: release
build-dev-release:
if: github.event_name == 'push' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release-'))
uses: ./.github/workflows/generate_apk.yml
with:
environment: dev
type: release

View File

@@ -6,7 +6,6 @@ on:
environment:
description: Choose build environment
required: true
default: qa
type: choice
options:
- qa
@@ -14,11 +13,20 @@ on:
type:
description: Choose build type
required: true
default: debug
type: choice
options:
- debug
- release
workflow_call:
inputs:
environment:
description: Build environment passed from caller workflow
required: true
type: string
type:
description: Build type passed from caller workflow
required: true
type: string
env:
KEYSTORE_PASSWORD: android
@@ -41,23 +49,23 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Generate Release Keystore
if: github.event.inputs.type == 'release'
if: github.event.inputs.type == 'release' || inputs.type == 'release'
run: keytool -genkey -v -keystore app/navi-release-key.jks -storepass $KEYSTORE_PASSWORD -alias $KEYSTORE_ALIAS -keypass $KEYSTORE_ALIAS_PASSWORD -keyalg RSA -keysize 2048 -validity 10000 -dname "cn=Android Build CI, ou=Android Team, o=Navi, l=Bengaluru, st=Karnataka, c=IN"
- name: Assemble with Stacktrace - QA Debug
if: github.event.inputs.environment == 'qa' && github.event.inputs.type == 'debug'
if: (github.event.inputs.environment == 'qa' || inputs.environment == 'qa') && (github.event.inputs.type == 'debug' || inputs.type == 'debug')
run: ./gradlew assembleQaDebug --stacktrace
- name: Assemble with Stacktrace - DEV Debug
if: github.event.inputs.environment == 'dev' && github.event.inputs.type == 'debug'
if: (github.event.inputs.environment == 'dev' || inputs.environment == 'dev') && (github.event.inputs.type == 'debug' || inputs.type == 'debug')
run: ./gradlew assembleDevDebug --stacktrace
- name: Assemble with Stacktrace - QA Release
if: github.event.inputs.environment == 'qa' && github.event.inputs.type == 'release'
if: (github.event.inputs.environment == 'qa' || inputs.environment == 'qa') && (github.event.inputs.type == 'release' || inputs.type == 'release')
run: ./gradlew assembleQaRelease --stacktrace -PRELEASE_STORE_PASSWORD=$KEYSTORE_PASSWORD -PRELEASE_KEY_ALIAS=$KEYSTORE_ALIAS -PRELEASE_KEY_PASSWORD=$KEYSTORE_ALIAS_PASSWORD
- name: Assemble with Stacktrace - DEV Release
if: github.event.inputs.environment == 'dev' && github.event.inputs.type == 'release'
if: (github.event.inputs.environment == 'dev' || inputs.environment == 'dev') && (github.event.inputs.type == 'release' || inputs.type == 'release')
run: ./gradlew assembleDevRelease --stacktrace -PRELEASE_STORE_PASSWORD=$KEYSTORE_PASSWORD -PRELEASE_KEY_ALIAS=$KEYSTORE_ALIAS -PRELEASE_KEY_PASSWORD=$KEYSTORE_ALIAS_PASSWORD
- name: Upload APK as Artifact
uses: actions/upload-artifact@v3
with:
name: app-${{ github.event.inputs.environment }}-${{ github.event.inputs.type }}
path: app/build/outputs/apk/${{ github.event.inputs.environment }}/${{ github.event.inputs.type }}/
name: app-${{ github.event.inputs.environment || inputs.environment }}-${{ github.event.inputs.type || inputs.type }}
path: app/build/outputs/apk/${{ github.event.inputs.environment || inputs.environment }}/${{ github.event.inputs.type || inputs.type }}/
retention-days: 30