From ad8850697e409b2c911bd05962edf14d47707932 Mon Sep 17 00:00:00 2001 From: yssk22 Date: Thu, 19 Dec 2024 04:09:58 +0000 Subject: [PATCH] [expo] extract env screts in Github Action. **Summary** We use eas-{env} for Github Environment and set secrets. **Test** - Github action with main branch **Issue** - #155 --- .github/workflows/eas-build-android.yml | 36 ++++++++++++++++--------- expo/scripts/eas-githubaction-pre.sh | 15 +++++++++++ 2 files changed, 38 insertions(+), 13 deletions(-) create mode 100755 expo/scripts/eas-githubaction-pre.sh diff --git a/.github/workflows/eas-build-android.yml b/.github/workflows/eas-build-android.yml index b4fd40dd..08491aca 100644 --- a/.github/workflows/eas-build-android.yml +++ b/.github/workflows/eas-build-android.yml @@ -1,4 +1,4 @@ -name: EAS - Build - Android +name: EAS - Build Android on: workflow_dispatch: inputs: @@ -11,30 +11,40 @@ on: - dev - beta - prod +env: + NODE_VERSION: 22.3.0 + EAS_VERSION: 13.4.2 + JAVA_VERSION: 17 jobs: - build: + build-dev: runs-on: ubuntu-latest + if: ${{ (inputs.config == 'dev') }} environment: - name: eas-${{inputs.platform}} + name: eas-dev steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: "22.3.0" + node-version: ${{ env.NODE_VERSION }} cache: "yarn" cache-dependency-path: "expo/package.json" - uses: expo/expo-github-action@v8 with: - eas-version: 13.4.2 + eas-version: ${{ env.EAS_VERSION }} token: ${{ secrets.EXPO_TOKEN }} - - run: cd expo && yarn install - - if: ${{ ((inputs.config == 'prod') || (inputs.config == 'beta')) }} - run: cd expo && ./scripts/eas.sh build --profile ${{inputs.config}} --platform android --local --output ./build/hpapp-${{inputs.config}}.aab + - uses: actions/setup-java@v3 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: "temurin" + - uses: android-actions/setup-android@v3 + - run: cd expo && ./scripts/eas-githubaction-pre.sh env: HPAPP_CONFIG_NAME: ${{inputs.config}} - HPAPP_CONFIG_PLATFORM: ${{inputs.platform}} - - if: ${{ ((inputs.config != 'prod') && (inputs.config != 'beta')) }} - run: cd expo && ./scripts/eas.sh build --profile dev --platform android --local --output ./build/hpapp-${{inputs.config}}.apk + SECRETS_JSON: ${{ secrets.SECRETS_JSON }} + GOOGLE_SERVICES_INFO_PLIST: ${{ secrets.GOOGLE_SERVICES_INFO_PLIST }} + GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} + - run: cd expo && yarn install + - run: cd expo && ./scripts/eas.sh build --profile dev --platform android --local --output ./build/hpapp-${{inputs.config}}.apk env: - HPAPP_CONFIG_NAME: dev - HPAPP_CONFIG_PLATFORM: ${{ inputs.platform }} + HPAPP_CONFIG_NAME: ${{inputs.config}} + NODE_ENV: production diff --git a/expo/scripts/eas-githubaction-pre.sh b/expo/scripts/eas-githubaction-pre.sh new file mode 100755 index 00000000..898a545f --- /dev/null +++ b/expo/scripts/eas-githubaction-pre.sh @@ -0,0 +1,15 @@ +#!/bin/bash +BASEDIR=$(dirname $0)/.. + +if [ -z $HPAPP_CONFIG_NAME ]; then + echo "HPAPP_CONFIG_NAME is not defined." + exit 1 +fi + +## extract environment screts +echo '$SECRETS_JSON' | envsubst > $BASEDIR/config/$HPAPP_CONFIG_NAME/secrets.json +echo '$GOOGLE_SERVICES_INFO_PLIST' | envsubst > $BASEDIR/config/$HPAPP_CONFIG_NAME/GoogleService-Info.plist +echo '$GOOGLE_SERVICES_JSON' | envsubst > $BASEDIR/config/$HPAPP_CONFIG_NAME/google-services.json + +## remove .gitignore as eas still ignore those files +rm $BASEDIR/config/$HPAPP_CONFIG_NAME/.gitignore \ No newline at end of file