Update dependency python to 3.14 #653
This file contains hidden or 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: CI Commit Build | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| build_artifact: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Free Disk Space (Ubuntu) | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| tool-cache: true | |
| android: false | |
| dotnet: true | |
| haskell: true | |
| large-packages: true | |
| docker-images: true | |
| swap-storage: true | |
| - name: Checkout Code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get Commit SHA | |
| id: vars | |
| run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Setup Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| version: '3.38.9' # Use specific stable version that meets requirements | |
| cache: true | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Strip signing config | |
| run: | | |
| # Strip signing config to build debug APK safely without keystores | |
| # Handle both .gradle and .gradle.kts files | |
| sed -i 's/signingConfig = signingConfigs.getByName("release")//g' android/app/build.gradle || true | |
| sed -i 's/signingConfig = signingConfigs.getByName("release")//g' android/app/build.gradle.kts || true | |
| - name: Build APK (Unique ID) | |
| run: | | |
| # Inject the short SHA into the Application ID to allow side-by-side testing | |
| # This replaces the existing applicationId with a unique one for this commit | |
| sed -i 's/applicationId = ".*"/applicationId = "com.updatium.ci.${{ steps.vars.outputs.sha_short }}"/g' android/app/build.gradle || true | |
| # Build the debug APK for the normal flavor | |
| flutter build apk --debug --flavor normal | |
| mkdir -p build/outputs/artifacts/ | |
| cp build/app/outputs/flutter-apk/app-normal-debug.apk build/outputs/artifacts/updatium-${{ steps.vars.outputs.sha_short }}.apk | |
| - name: Upload Build Artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: Updatium-Commit-${{ steps.vars.outputs.sha_short }} | |
| path: build/outputs/artifacts/updatium-${{ steps.vars.outputs.sha_short }}.apk | |
| retention-days: 14 # Keep artifacts for 14 days to save space | |
| auto_reject_on_failure: | |
| runs-on: ubuntu-latest | |
| needs: build_artifact | |
| if: failure() && github.event_name == 'pull_request' && needs.build_artifact.result == 'failure' | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| steps: | |
| - name: Auto-Reject PR on Build Failure | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| // Wait a moment to ensure build is completely finished | |
| await new Promise(resolve => setTimeout(resolve, 5000)); | |
| const { data: reviews } = await github.rest.pulls.listReviews({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| }); | |
| // Check if CI has already reviewed this PR | |
| const existingReview = reviews.find( | |
| (review) => | |
| review.user.login === 'github-actions[bot]' && | |
| (review.state === 'CHANGES_REQUESTED' || review.state === 'APPROVED') | |
| ); | |
| // Double-check that the build actually failed by checking job status | |
| const buildStatus = '${{ needs.build_artifact.result }}'; | |
| console.log(`Build artifact result: ${buildStatus}`); | |
| if (!existingReview && buildStatus === 'failure') { | |
| await github.rest.pulls.createReview({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| event: 'REQUEST_CHANGES', | |
| body: '🚫 **CI Build Failed**\n\nThe automated build process failed. Please review the build logs and fix the issues before requesting another review.\n\n**Next steps:**\n1. Check the build logs for specific errors\n2. Fix the identified issues\n3. Push your fixes to this branch\n4. The CI will automatically re-run\n\nOnce the build passes, this review will be dismissed automatically.' | |
| }); | |
| console.log(`Auto-rejected PR #${context.issue.number} due to build failure`); | |
| } else { | |
| console.log(`PR #${context.issue.number} already has a review from CI or build did not fail (status: ${buildStatus})`); | |
| } | |
| auto_approve_on_success: | |
| runs-on: ubuntu-latest | |
| needs: build_artifact | |
| if: success() && github.event_name == 'pull_request' && needs.build_artifact.result == 'success' | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| steps: | |
| - name: Auto-Approve PR on Build Success | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| // Wait a moment to ensure build is completely finished | |
| await new Promise(resolve => setTimeout(resolve, 5000)); | |
| const { data: reviews } = await github.rest.pulls.listReviews({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| }); | |
| // Find and dismiss any existing CI rejection reviews | |
| const ciReviews = reviews.filter( | |
| (review) => | |
| review.user.login === 'github-actions[bot]' && | |
| review.state === 'CHANGES_REQUESTED' | |
| ); | |
| // Double-check that build actually succeeded | |
| const buildStatus = '${{ needs.build_artifact.result }}'; | |
| console.log(`Build artifact result: ${buildStatus}`); | |
| for (const review of ciReviews) { | |
| await github.rest.pulls.dismissReview({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| review_id: review.id, | |
| message: '✅ **CI Build Passed** - Automatically dismissing previous rejection as the build now succeeds.' | |
| }); | |
| } | |
| if (ciReviews.length > 0) { | |
| console.log(`Dismissed ${ciReviews.length} CI rejection reviews for PR #${context.issue.number}`); | |
| } else { | |
| console.log(`No CI rejection reviews found for PR #${context.issue.number} (status: ${buildStatus})`); | |
| } |