From 9ce8cf4c566d45900e1c04f6fb6ef60ff471c90d Mon Sep 17 00:00:00 2001 From: alperozturk Date: Tue, 8 Jul 2025 14:25:33 +0200 Subject: [PATCH 1/3] Comment on PR Signed-off-by: alperozturk --- .github/workflows/android.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index ab7ca3004..ca30c00b2 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-FileCopyrightText: 2025 Alper Ozturk # SPDX-FileCopyrightText: 2020-2024 Stefan Niedermann # SPDX-FileCopyrightText: 2023 Álvaro Brey # SPDX-License-Identifier: GPL-3.0-or-later @@ -12,6 +13,7 @@ on: permissions: contents: read + pull-requests: write jobs: validation: @@ -78,3 +80,15 @@ jobs: with: name: app-dev-debug path: app/build/outputs/apk/dev/debug/app-dev-debug.apk + + - name: Comment on PR + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'πŸŽ‰ Debug APK built and uploaded! You can find it in the [workflow artifacts](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).' + }) From f044591df77d01ca8c3c9c492be6a65b2d9fca90 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 17 Jul 2025 16:11:09 +0200 Subject: [PATCH 2/3] t1 Signed-off-by: alperozturk --- .github/workflows/android.yml | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index ca30c00b2..fa86ee427 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -81,14 +81,27 @@ jobs: name: app-dev-debug path: app/build/outputs/apk/dev/debug/app-dev-debug.apk - - name: Comment on PR - if: github.event_name == 'pull_request' - uses: actions/github-script@v7 - with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'πŸŽ‰ Debug APK built and uploaded! You can find it in the [workflow artifacts](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).' - }) + - name: Upload to Nextcloud and comment + env: + USER: ${{ secrets.NEXTCLOUD_USER }} + PASS: ${{ secrets.NEXTCLOUD_PASSWORD }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD: pr-${{ github.event.pull_request.number }}-${{ github.sha }} + PR: ${{ github.event.pull_request.number }} + PUBLIC_URL: https://www.kaminsky.me/nc-dev/android-artifacts + DAV_URL: https://nextcloud.kaminsky.me/remote.php/dav/files/${{ secrets.NEXTCLOUD_USER }}/android-artifacts + run: | + APK=$(find app/build/outputs/apk/qa/debug -name "qa-debug-*.apk" | head -n1) + [ -f "$APK" ] || { echo "APK not found"; exit 1; } + + curl -u "$USER:$PASS" -T "$APK" "$DAV_URL/$BUILD.apk" + qrencode -o "$PR.png" "$PUBLIC_URL/$BUILD.apk" + curl -u "$USER:$PASS" -T "$PR.png" "$DAV_URL/$BUILD.png" + + COMMENT="APK file: $PUBLIC_URL/$BUILD.apk\n\n![QR Code]($PUBLIC_URL/$BUILD.png)\n\nTo test this change or fix, download and install the APK above. It can run in parallel to your existing app." + + curl -s -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Content-Type: application/json" \ + -d "$(jq -n --arg body "$COMMENT" '{body: $body}')" \ + https://api.github.com/repos/${{ github.repository }}/issues/$PR/comments From 12268cc5f213ca51179235e5d787d714a9d19fe0 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 17 Jul 2025 16:17:59 +0200 Subject: [PATCH 3/3] t2 Signed-off-by: alperozturk --- .github/workflows/android.yml | 41 +++++++++++++++-------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index fa86ee427..76fc1b54d 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -81,27 +81,20 @@ jobs: name: app-dev-debug path: app/build/outputs/apk/dev/debug/app-dev-debug.apk - - name: Upload to Nextcloud and comment - env: - USER: ${{ secrets.NEXTCLOUD_USER }} - PASS: ${{ secrets.NEXTCLOUD_PASSWORD }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BUILD: pr-${{ github.event.pull_request.number }}-${{ github.sha }} - PR: ${{ github.event.pull_request.number }} - PUBLIC_URL: https://www.kaminsky.me/nc-dev/android-artifacts - DAV_URL: https://nextcloud.kaminsky.me/remote.php/dav/files/${{ secrets.NEXTCLOUD_USER }}/android-artifacts - run: | - APK=$(find app/build/outputs/apk/qa/debug -name "qa-debug-*.apk" | head -n1) - [ -f "$APK" ] || { echo "APK not found"; exit 1; } - - curl -u "$USER:$PASS" -T "$APK" "$DAV_URL/$BUILD.apk" - qrencode -o "$PR.png" "$PUBLIC_URL/$BUILD.apk" - curl -u "$USER:$PASS" -T "$PR.png" "$DAV_URL/$BUILD.png" - - COMMENT="APK file: $PUBLIC_URL/$BUILD.apk\n\n![QR Code]($PUBLIC_URL/$BUILD.png)\n\nTo test this change or fix, download and install the APK above. It can run in parallel to your existing app." - - curl -s -X POST \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Content-Type: application/json" \ - -d "$(jq -n --arg body "$COMMENT" '{body: $body}')" \ - https://api.github.com/repos/${{ github.repository }}/issues/$PR/comments + - name: Comment on PR with artifact link + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + script: | + const runId = process.env.GITHUB_RUN_ID; + const repo = context.repo.repo; + const owner = context.repo.owner; + const prNumber = context.payload.pull_request.number; + const artifactUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`; + + github.rest.issues.createComment({ + owner, + repo, + issue_number: prNumber, + body: `πŸŽ‰ Debug APK built and uploaded! You can download it from the [workflow artifacts](${artifactUrl}).` + }); \ No newline at end of file