From bf9ab8a35997a71199f0674df2dcf8c4a0ba9996 Mon Sep 17 00:00:00 2001 From: Sujal Date: Wed, 19 Feb 2025 16:29:09 +0530 Subject: [PATCH] Update android.yml --- .github/workflows/android.yml | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 958c13fda..529b64652 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -2,6 +2,10 @@ name: Android CI on: [push, pull_request, workflow_dispatch] +permissions: + pull-requests: write + contents: read + concurrency: group: build-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true @@ -102,3 +106,36 @@ jobs: with: name: prodDebugAPK path: app/build/outputs/apk/prod/debug/app-*.apk + + - name: Comment on PR with APK download links + if: github.event_name == 'pull_request' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.runId + }); + + const betaArtifact = artifacts.find(artifact => artifact.name === "betaDebugAPK"); + const prodArtifact = artifacts.find(artifact => artifact.name === "prodDebugAPK"); + + if (betaArtifact && prodArtifact) { + const betaDownloadUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/suites/${context.runId}/artifacts/${betaArtifact.id}`; + const prodDownloadUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/suites/${context.runId}/artifacts/${prodArtifact.id}`; + + const commentBody = ` + 📱 **Apk for pull request is ready to see the changes** 📱 + - [Download Beta APK](${betaDownloadUrl}) + - [Download Prod APK](${prodDownloadUrl}) + `; + + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + }