From c9bc8bc55d09c8c6bb97a53de38d9e6d317bedcb Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Mon, 27 Jan 2025 20:58:59 +0100 Subject: [PATCH] PR check workflow improvements (#217) * fixed builds being pushed to main * restore firebase options in workflows * moved firebase options to gitignore * restore firebase options in workflows * moved firebase options to gitignore * migrated to artifacts v4 * split analyze workflow for stub * skip artifact upload for PR checks * typo * updated firebase stub * stub check * typo * Revert "stub check" This reverts commit ff2b7cdc23bee79f5c8734ca05722f94cb4a50f1. --- .github/workflows/build_apk.yml | 9 +++++++++ .github/workflows/build_ipa.yml | 9 +++++++++ .github/workflows/create_release.yml | 2 ++ .github/workflows/pr_check.yml | 27 ++++++++++----------------- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build_apk.yml b/.github/workflows/build_apk.yml index fc260ce..d0af2de 100644 --- a/.github/workflows/build_apk.yml +++ b/.github/workflows/build_apk.yml @@ -30,6 +30,10 @@ on: type: boolean description: Use stage backend default: true + upload-artifact: + type: boolean + description: Upload build to artifacts + default: true workflow_dispatch: inputs: version: @@ -59,6 +63,10 @@ on: type: boolean description: Use stage backend default: true + upload-artifact: + type: boolean + description: Upload build to artifacts + default: true env: BUILD_ARGS: --release --flavor ${{ inputs.flavor }} -t lib/main_${{ inputs.flavor }}.dart @@ -136,6 +144,7 @@ jobs: run: flutter build ${{ inputs.binary-type }} $BUILD_ARGS - name: Upload ${{ inputs.binary-type }} to artifacts + if: ${{ inputs.upload-artifact }} uses: actions/upload-artifact@v4 with: name: m3_lightmeter_${{ inputs.binary-type }} diff --git a/.github/workflows/build_ipa.yml b/.github/workflows/build_ipa.yml index 5a22573..4313da1 100644 --- a/.github/workflows/build_ipa.yml +++ b/.github/workflows/build_ipa.yml @@ -22,6 +22,10 @@ on: type: boolean description: Use stage backend default: true + upload-artifact: + type: boolean + description: Upload build to artifacts + default: true workflow_dispatch: inputs: version: @@ -36,6 +40,10 @@ on: type: boolean description: Use stage backend default: true + upload-artifact: + type: boolean + description: Upload build to artifacts + default: true env: FLAVOR: "prod" @@ -135,6 +143,7 @@ jobs: --export-options-plist=ios/Runner/ExportOptions.plist - name: Upload artifact + if: ${{ inputs.upload-artifact }} uses: actions/upload-artifact@v4 with: name: m3_lightmeter_ipa diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 74814a6..ad5f280 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -86,6 +86,7 @@ jobs: with: binary-type: ${{ matrix.binary-type }} flavor: prod + upload-artifact: true stage-backend: false version: ${{ inputs.version }} @@ -96,6 +97,7 @@ jobs: uses: ./.github/workflows/build_ipa.yml secrets: inherit with: + upload-artifact: true stage-backend: false version: ${{ inputs.version }} diff --git a/.github/workflows/pr_check.yml b/.github/workflows/pr_check.yml index c236595..cdb6b2d 100644 --- a/.github/workflows/pr_check.yml +++ b/.github/workflows/pr_check.yml @@ -16,6 +16,9 @@ jobs: name: Analyze & test runs-on: macos-14 timeout-minutes: 10 + env: + EMPTY_CONSTANTS: Y29uc3QgU3RyaW5nIGlhcFNlcnZlclVybCA9ICcnOwpjb25zdCBTdHJpbmcgaXNzdWVzUmVwb3J0VXJsID0gJyc7CmNvbnN0IFN0cmluZyBzb3VyY2VDb2RlVXJsID0gJyc7CmNvbnN0IFN0cmluZyBjb250YWN0RW1haWwgPSAnJzsK + EMPTY_FIREBASE_OPTIONS: Ly8gaWdub3JlX2Zvcl9maWxlOiB0eXBlPWxpbnQKaW1wb3J0ICdwYWNrYWdlOmZpcmViYXNlX2NvcmUvZmlyZWJhc2VfY29yZS5kYXJ0JyBzaG93IEZpcmViYXNlT3B0aW9uczsKY2xhc3MgRGVmYXVsdEZpcmViYXNlT3B0aW9ucyB7c3RhdGljIEZpcmViYXNlT3B0aW9ucyBnZXQgY3VycmVudFBsYXRmb3JtID0+RmlyZWJhc2VPcHRpb25zKGFwaUtleTogJycsIGFwcElkOiAnJywgbWVzc2FnaW5nU2VuZGVySWQ6ICcnLCBwcm9qZWN0SWQ6ICcnKTt9Cg== steps: - uses: 8BitJonny/gh-get-current-pr@2.2.0 id: PR @@ -37,9 +40,12 @@ jobs: run: bash ./.github/scripts/stub_iap.sh - name: Restore secrets + env: + CONSTANTS: ${{ steps.fetch-iap.conclusion == 'success' && secrets.CONSTANTS || env.EMPTY_CONSTANTS }} + FIREBASE_OPTIONS: ${{ steps.fetch-iap.conclusion == 'success' && secrets.FIREBASE_OPTIONS || env.EMPTY_FIREBASE_OPTIONS }} run: | - bash .github/scripts/restore_from_base64.sh "${{ secrets.CONSTANTS }}" "lib/constants.dart" - bash .github/scripts/restore_from_base64.sh "${{ secrets.FIREBASE_OPTIONS }}" "lib/firebase_options.dart" + bash .github/scripts/restore_from_base64.sh "${{ env.CONSTANTS }}" "lib/constants.dart" + bash .github/scripts/restore_from_base64.sh "${{ env.FIREBASE_OPTIONS }}" "lib/firebase_options.dart" - uses: subosito/flutter-action@v2 with: @@ -98,6 +104,7 @@ jobs: with: binary-type: apk flavor: prod + upload-artifact: false stage-backend: false version: "1.0.0" @@ -108,20 +115,6 @@ jobs: uses: ./.github/workflows/build_ipa.yml secrets: inherit with: + upload-artifact: false stage-backend: false version: "1.0.0" - - cleanup: - name: Cleanup - if: ${{ always() }} - needs: [build-android, build-ios] - runs-on: ubuntu-latest - steps: - - name: Delete release artifacts - uses: geekyeggo/delete-artifact@v2 - with: - failOnError: false - name: | - m3_lightmeter_apk - m3_lightmeter_appbundle - m3_lightmeter_ipa