revert prior attempt

Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
This commit is contained in:
parneet-guraya 2025-02-28 02:35:12 +05:30
parent fa24b93830
commit dbc0668d29
No known key found for this signature in database
GPG key ID: 63B807C4B2A9064B
2 changed files with 1 additions and 112 deletions

View file

@ -1,96 +0,0 @@
name: Android CI Comment
on:
workflow_run:
workflows: ["Android CI"]
types: [completed]
branches: [main]
permissions:
issues: write
jobs:
comment:
name: Comment on PR with APK links
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Download Run ID Artifact
uses: actions/download-artifact@v4
with:
name: run-id
run-id: ${{ github.event.workflow_run.id }}
- name: Read Run ID
id: read-run-id
run: echo "RUN_ID=$(cat run_id.txt)" >> $GITHUB_ENV
- name: Comment on PR with APK download links
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/github-script@v6
with:
script: |
try {
const token = process.env.GH_TOKEN;
if (!token) {
throw new Error('GITHUB_TOKEN is not set.');
}
const runId = "${{ env.RUN_ID }}";
if (!runId) {
throw new Error('Run ID not found.');
}
// Get the PR number from the workflow_run event
const prNumber = ${{ github.event.workflow_run.pull_requests[0].number }};
if (!prNumber) {
console.log('No PR number found in workflow_run event.');
return;
}
const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId
});
if (!artifacts || artifacts.length === 0) {
console.log('No artifacts found for this workflow run.');
return;
}
const betaArtifact = artifacts.find(artifact => artifact.name === "betaDebugAPK");
const prodArtifact = artifacts.find(artifact => artifact.name === "prodDebugAPK");
if (!betaArtifact || !prodArtifact) {
console.log('Could not find both Beta and Prod APK artifacts.');
console.log('Available artifacts:', artifacts.map(a => a.name).join(', '));
return;
}
const betaDownloadUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/suites/${runId}/artifacts/${betaArtifact.id}`;
const prodDownloadUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/suites/${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: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
console.log('Successfully posted comment with APK download links');
} catch (error) {
console.error('Error in PR comment creation:', error);
core.setFailed(`Workflow failed: ${error.message}`);
}

View file

@ -1,10 +1,6 @@
name: Android CI name: Android CI
on: [push, pull_request, workflow_dispatch] on: [push, pull_request, workflow_dispatch]
permissions:
contents: read
actions: read
concurrency: concurrency:
group: build-${{ github.event.pull_request.number || github.ref }} group: build-${{ github.event.pull_request.number || github.ref }}
@ -106,14 +102,3 @@ jobs:
with: with:
name: prodDebugAPK name: prodDebugAPK
path: app/build/outputs/apk/prod/debug/app-*.apk path: app/build/outputs/apk/prod/debug/app-*.apk
- name: Store Workflow Run ID
if: github.event_name == 'pull_request'
run: echo "${{ github.run_id }}" > run_id.txt
- name: Upload Run ID as Artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: run-id
path: run_id.txt