From cd526c4065065c8684195aaa86ccecdf073b9b78 Mon Sep 17 00:00:00 2001 From: Michael Chinweike Date: Fri, 3 Oct 2025 16:30:15 +0100 Subject: [PATCH 1/5] impl. mocked script --- .github/workflows/build-and-submit-prod.yml | 43 --------- .github/workflows/ota-publish.yml | 32 ------- .github/workflows/preview-android-feature.yml | 89 +++++++++++++------ 3 files changed, 61 insertions(+), 103 deletions(-) delete mode 100644 .github/workflows/build-and-submit-prod.yml delete mode 100644 .github/workflows/ota-publish.yml diff --git a/.github/workflows/build-and-submit-prod.yml b/.github/workflows/build-and-submit-prod.yml deleted file mode 100644 index 72bb852..0000000 --- a/.github/workflows/build-and-submit-prod.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Build & Submit Production - -on: - pull_request: - branches: [main] # Target branch is 'main' - paths-ignore: ["docs/**"] - types: [opened, reopened] # Avoid triggering on new commits - -jobs: - build: - if: github.head_ref == 'dev' # Only run if PR is from 'dev' - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: yarn - - - name: Setup EAS - uses: expo/expo-github-action@v8 - with: - eas-version: 16.1.0 - token: ${{ secrets.EAS_TOKEN }} - - - name: Install dependencies - run: yarn install - - - name: Trigger Android Production Build - run: eas build --platform android --profile production --non-interactive --no-wait - - # - name: Trigger iOS Production Build - # run: eas build --platform ios --profile production --non-interactive --no-wait - - - name: Submit Android Build to Store - run: eas submit --platform android --profile production --non-interactive - - # - name: Submit iOS Build to Store - # run: eas submit --platform ios --profile production --non-interactive diff --git a/.github/workflows/ota-publish.yml b/.github/workflows/ota-publish.yml deleted file mode 100644 index bdac2e7..0000000 --- a/.github/workflows/ota-publish.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: OTA Publish to Production - -on: - pull_request: - branches: [main] - types: [opened, reopened] -jobs: - publish-ota: - if: startsWith(github.head_ref, 'ota/') - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: yarn - - - name: Setup EAS - uses: expo/expo-github-action@v8 - with: - eas-version: 16.1.0 - token: ${{ secrets.EAS_TOKEN }} - - - name: Install dependencies - run: yarn install - - - name: Publish OTA to Production Channel - run: eas update --channel production --platform android --non-interactive diff --git a/.github/workflows/preview-android-feature.yml b/.github/workflows/preview-android-feature.yml index 38933db..de560a2 100644 --- a/.github/workflows/preview-android-feature.yml +++ b/.github/workflows/preview-android-feature.yml @@ -1,38 +1,71 @@ -name: Preview Android Build (Feature Branch) +# name: Preview Android Build (Feature Branch) + +# on: +# pull_request: +# branches: [dev] +# paths-ignore: +# - "**.md" +# - "docs/**" +# types: [opened, reopened] + +# jobs: +# build: +# name: Build Android Preview +# if: startsWith(github.head_ref, 'feature/') +# runs-on: ubuntu-latest + +# steps: +# - name: Checkout repository +# uses: actions/checkout@v3 + +# - name: Setup Node +# uses: actions/setup-node@v3 +# with: +# node-version: 18 +# cache: yarn + +# - name: Setup EAS +# uses: expo/expo-github-action@v8 +# with: +# eas-version: latest +# token: ${{ secrets.EAS_TOKEN }} + +# - name: Install dependencies +# run: yarn install + +# - name: Trigger EAS Android build (preview) +# id: eas_build +# run: eas build --platform android --profile preview --non-interactive + +name: Test PR Comment on: - pull_request: - branches: [dev] - paths-ignore: - - "**.md" - - "docs/**" - types: [opened, reopened] + workflow_dispatch: + inputs: + pr_number: + description: 'Pull Request Number' + required: true + type: string jobs: - build: - name: Build Android Preview - if: startsWith(github.head_ref, 'feature/') + test: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Echo test 1 + run: echo "Running mocked test 1" - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: yarn + - name: Echo test 2 + run: echo "Running mocked test 2" - - name: Setup EAS - uses: expo/expo-github-action@v8 + - name: Add mock link as PR comment + uses: actions/github-script@v7 with: - eas-version: latest - token: ${{ secrets.EAS_TOKEN }} - - - name: Install dependencies - run: yarn install - - - name: Trigger EAS Android build (preview) - id: eas_build - run: eas build --platform android --profile preview --non-interactive \ No newline at end of file + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: Number('${{ github.event.inputs.pr_number }}'), + owner: context.repo.owner, + repo: context.repo.repo, + body: '🔗 [Sample Link for Test Build](https://example.com/mock-build)' + }) \ No newline at end of file From fbb29a37b4144b3beecdd612de0ae1ee126b042f Mon Sep 17 00:00:00 2001 From: Michael Chinweike Date: Fri, 3 Oct 2025 16:35:02 +0100 Subject: [PATCH 2/5] adde sample workflow --- .github/workflows/preview-android-feature.yml | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/preview-android-feature.yml b/.github/workflows/preview-android-feature.yml index de560a2..667b44e 100644 --- a/.github/workflows/preview-android-feature.yml +++ b/.github/workflows/preview-android-feature.yml @@ -37,26 +37,28 @@ # id: eas_build # run: eas build --platform android --profile preview --non-interactive -name: Test PR Comment +name: Sample PR Comment for Testing on: - workflow_dispatch: - inputs: - pr_number: - description: 'Pull Request Number' - required: true - type: string + pull_request: + branches: [dev] + types: [opened, reopened, synchronize] + paths-ignore: + - "**.md" + - "docs/**" jobs: test: + name: Mocked Test Scripts + if: startsWith(github.head_ref, 'feature/') runs-on: ubuntu-latest steps: - - name: Echo test 1 - run: echo "Running mocked test 1" + - name: Mock Script 1 + run: echo "Running mock test script 1" - - name: Echo test 2 - run: echo "Running mocked test 2" + - name: Mock Script 2 + run: echo "Running mock test script 2" - name: Add mock link as PR comment uses: actions/github-script@v7 @@ -64,7 +66,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | github.rest.issues.createComment({ - issue_number: Number('${{ github.event.inputs.pr_number }}'), + issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: '🔗 [Sample Link for Test Build](https://example.com/mock-build)' From 4834264ec0e67f1674cad6ddb2cc9da3b3cb15fe Mon Sep 17 00:00:00 2001 From: Michael Chinweike Date: Fri, 3 Oct 2025 16:40:31 +0100 Subject: [PATCH 3/5] adde sample workflow --- .github/workflows/preview-android-feature.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/preview-android-feature.yml b/.github/workflows/preview-android-feature.yml index 667b44e..a694192 100644 --- a/.github/workflows/preview-android-feature.yml +++ b/.github/workflows/preview-android-feature.yml @@ -52,6 +52,12 @@ jobs: name: Mocked Test Scripts if: startsWith(github.head_ref, 'feature/') runs-on: ubuntu-latest + + # Add this permissions block + permissions: + contents: read + issues: write + pull-requests: write steps: - name: Mock Script 1 From 8e0c767b5dff39e57d795873c9cad40f806a9332 Mon Sep 17 00:00:00 2001 From: Michael Chinweike Date: Fri, 3 Oct 2025 16:44:27 +0100 Subject: [PATCH 4/5] adde sample workflow --- .github/workflows/preview-android-feature.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/preview-android-feature.yml b/.github/workflows/preview-android-feature.yml index a694192..94d5bb3 100644 --- a/.github/workflows/preview-android-feature.yml +++ b/.github/workflows/preview-android-feature.yml @@ -75,5 +75,13 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: '🔗 [Sample Link for Test Build](https://example.com/mock-build)' + body: `## 📦 Test Build Available + + Hi QA Team! 👋 + + A new test build has been generated for this pull request and is ready for testing. + + **📱 Download APK:** [Click here to download](https://example.com/mock-build) + + Please test the new changes and report any issues found. Thank you! 🙏` }) \ No newline at end of file From c9f50b73c00c4b51a3b9b82f1ecbf0844fe8427a Mon Sep 17 00:00:00 2001 From: Michael Chinweike Date: Fri, 3 Oct 2025 16:55:53 +0100 Subject: [PATCH 5/5] refactor: update Android preview workflow and add build failure handling --- .github/workflows/preview-android-feature.yml | 179 +++++++++++++++--- eas.json | 3 + 2 files changed, 158 insertions(+), 24 deletions(-) diff --git a/.github/workflows/preview-android-feature.yml b/.github/workflows/preview-android-feature.yml index 94d5bb3..4bd121f 100644 --- a/.github/workflows/preview-android-feature.yml +++ b/.github/workflows/preview-android-feature.yml @@ -37,7 +37,56 @@ # id: eas_build # run: eas build --platform android --profile preview --non-interactive -name: Sample PR Comment for Testing +# name: Sample PR Comment for Testing + +# on: +# pull_request: +# branches: [dev] +# types: [opened, reopened, synchronize] +# paths-ignore: +# - "**.md" +# - "docs/**" + +# jobs: +# test: +# name: Mocked Test Scripts +# if: startsWith(github.head_ref, 'feature/') +# runs-on: ubuntu-latest + +# # Add this permissions block +# permissions: +# contents: read +# issues: write +# pull-requests: write + +# steps: +# - name: Mock Script 1 +# run: echo "Running mock test script 1" + +# - name: Mock Script 2 +# run: echo "Running mock test script 2" + +# - name: Add mock link as PR comment +# uses: actions/github-script@v7 +# with: +# github-token: ${{ secrets.GITHUB_TOKEN }} +# script: | +# github.rest.issues.createComment({ +# issue_number: context.issue.number, +# owner: context.repo.owner, +# repo: context.repo.repo, +# body: `## 📦 Test Build Available + +# Hi QA Team! 👋 + +# A new test build has been generated for this pull request and is ready for testing. + +# **📱 Download APK:** [Click here to download](https://example.com/mock-build) + +# Please test the new changes and report any issues found. Thank you! 🙏` +# }) + +name: Preview Android Build (Feature Branch) on: pull_request: @@ -48,40 +97,122 @@ on: - "docs/**" jobs: - test: - name: Mocked Test Scripts + build: + name: Build Android Preview if: startsWith(github.head_ref, 'feature/') runs-on: ubuntu-latest - - # Add this permissions block - permissions: - contents: read - issues: write - pull-requests: write - steps: - - name: Mock Script 1 - run: echo "Running mock test script 1" + - name: Checkout repository + uses: actions/checkout@v3 - - name: Mock Script 2 - run: echo "Running mock test script 2" + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: yarn - - name: Add mock link as PR comment + - name: Setup EAS + uses: expo/expo-github-action@v8 + with: + eas-version: latest + token: ${{ secrets.EAS_TOKEN }} + + - name: Install dependencies + run: yarn install + + - name: Trigger EAS Android build (preview) + id: eas_build + continue-on-error: true + run: | + eas build --platform android --profile preview --non-interactive --json > eas_output.json + cat eas_output.json + echo "BUILD_EXIT_CODE=$?" >> $GITHUB_ENV + + - name: Extract build information + id: extract_info + if: always() + run: | + if [ -f eas_output.json ]; then + BUILD_ID=$(jq -r '.[] | select(.platform == "android") | .id' eas_output.json 2>/dev/null || echo "") + BUILD_URL=$(jq -r '.[] | select(.platform == "android") | .buildDetailsUrl' eas_output.json 2>/dev/null || echo "") + ARTIFACT_URL=$(jq -r '.[] | select(.platform == "android") | .artifacts.buildUrl' eas_output.json 2>/dev/null || echo "") + + echo "BUILD_ID=$BUILD_ID" >> $GITHUB_ENV + echo "BUILD_URL=$BUILD_URL" >> $GITHUB_ENV + echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV + fi + + - name: Wait for build completion and get APK link + id: wait_build + if: env.BUILD_ID != '' && env.BUILD_EXIT_CODE == '0' + timeout-minutes: 30 + run: | + BUILD_ID="${{ env.BUILD_ID }}" + echo "Waiting for build $BUILD_ID to complete..." + + while true; do + STATUS=$(eas build:view $BUILD_ID --json | jq -r '.[0].status') + echo "Current status: $STATUS" + + if [ "$STATUS" = "finished" ]; then + APK_URL=$(eas build:view $BUILD_ID --json | jq -r '.[0].artifacts.buildUrl') + echo "APK_URL=$APK_URL" >> $GITHUB_ENV + echo "Build completed successfully!" + break + elif [ "$STATUS" = "errored" ] || [ "$STATUS" = "canceled" ]; then + echo "BUILD_FAILED=true" >> $GITHUB_ENV + echo "Build failed with status: $STATUS" + break + fi + + sleep 30 + done + + - name: Comment success on PR uses: actions/github-script@v7 + if: env.APK_URL != '' && env.BUILD_FAILED != 'true' with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | + const body = `## 🚀 Android Preview Build Ready! + + ✅ **Build Status:** Successful + + 📦 **Download APK:** [Click here to download](${process.env.APK_URL}) + + 📊 **Build Details:** [View on Expo](${process.env.BUILD_URL}) + + --- + *Build ID: \`${process.env.BUILD_ID}\`*`; + github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `## 📦 Test Build Available - - Hi QA Team! 👋 - - A new test build has been generated for this pull request and is ready for testing. + body: body + }); - **📱 Download APK:** [Click here to download](https://example.com/mock-build) - - Please test the new changes and report any issues found. Thank you! 🙏` - }) \ No newline at end of file + - name: Comment failure on PR + uses: actions/github-script@v7 + if: always() && (env.BUILD_FAILED == 'true' || env.BUILD_EXIT_CODE != '0') + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const buildUrl = process.env.BUILD_URL || 'Build URL not available'; + const body = `## ❌ Android Preview Build Failed + + ⚠️ **Build Status:** Failed + + 🔗 **Error Details:** [View build logs on Expo](${buildUrl}) + + Please check the logs for more information about the failure. + + --- + *Build ID: \`${process.env.BUILD_ID || 'N/A'}\`*`; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body + }); \ No newline at end of file diff --git a/eas.json b/eas.json index ade6983..7c49119 100644 --- a/eas.json +++ b/eas.json @@ -16,6 +16,9 @@ "channel": "staging", "ios": { "resourceClass": "m-medium" + }, + "android": { + "buildType": "apk" } }, "production": {