From dd024d0e5018de98fc31c1d630cb96bb3c00326d Mon Sep 17 00:00:00 2001 From: Adrian Castro <22133246+castdrian@users.noreply.github.com> Date: Wed, 19 Aug 2026 20:26:21 +0200 Subject: [PATCH] ci: comment all platform build artifacts --- .github/workflows/ios-artifact-comment.yml | 55 --------------- .../workflows/platform-artifact-comment.yml | 68 +++++++++++++++++++ .github/workflows/switch-artifact-comment.yml | 55 --------------- 3 files changed, 68 insertions(+), 110 deletions(-) delete mode 100644 .github/workflows/ios-artifact-comment.yml create mode 100644 .github/workflows/platform-artifact-comment.yml delete mode 100644 .github/workflows/switch-artifact-comment.yml diff --git a/.github/workflows/ios-artifact-comment.yml b/.github/workflows/ios-artifact-comment.yml deleted file mode 100644 index 3ba5386f..00000000 --- a/.github/workflows/ios-artifact-comment.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: iOS artifact comment - -on: - workflow_run: - workflows: [ci] - types: [completed] - -permissions: - contents: read - issues: write - pull-requests: write - -jobs: - comment: - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' - runs-on: ubuntu-latest - steps: - - id: artifact - env: - GH_TOKEN: ${{ github.token }} - RUN_ID: ${{ github.event.workflow_run.id }} - HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} - HEAD_REPOSITORY: ${{ github.event.workflow_run.head_repository.full_name }} - run: | - artifact_id="$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts" --jq '.artifacts[] | select(.name == "gen1recomp++-ios-ipa") | .id')" - [ -n "$artifact_id" ] || exit 0 - head_owner="${HEAD_REPOSITORY%%/*}" - pr_number="$(gh api "repos/$GITHUB_REPOSITORY/pulls?state=open&head=$head_owner:$HEAD_BRANCH" --jq '.[0].number // empty')" - [ -n "$pr_number" ] || exit 0 - echo "artifact_url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts/$artifact_id" >> "$GITHUB_OUTPUT" - echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT" - # Upsert via comment-tag only — do not delete-all bot comments (clobbers Switch). - - name: Get build info - id: build-info - env: - HEAD_SHA: ${{ github.event.workflow_run.head_sha }} - run: | - commit_hash="$(printf '%s' "$HEAD_SHA" | cut -c1-7)" - build_time="$(date "+%Y-%m-%d %H:%M:%S")" - echo "hash=$commit_hash" >> "$GITHUB_OUTPUT" - echo "time=$build_time" >> "$GITHUB_OUTPUT" - - name: comment iOS artifact - if: steps.artifact.outputs.pr_number != '' - uses: thollander/actions-comment-pull-request@v3 - with: - message: | - [gen1recomp++.ipa](${{ steps.artifact.outputs.artifact_url }}) - - **Commit**: [#${{ steps.build-info.outputs.hash }}](https://github.com/${{ github.event.workflow_run.head_repository.full_name }}/commit/${{ github.event.workflow_run.head_sha }}) - **Build Time**: `${{ steps.build-info.outputs.time }}` - - This comment was automatically generated. [View workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}) - pr-number: ${{ steps.artifact.outputs.pr_number }} - comment-tag: ios-build-result - github-token: ${{ github.token }} diff --git a/.github/workflows/platform-artifact-comment.yml b/.github/workflows/platform-artifact-comment.yml new file mode 100644 index 00000000..d1182cec --- /dev/null +++ b/.github/workflows/platform-artifact-comment.yml @@ -0,0 +1,68 @@ +name: platform artifact comment + +on: + workflow_run: + workflows: [ci] + types: [completed] + +permissions: + contents: read + issues: write + pull-requests: write + +jobs: + comment: + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest + steps: + - id: artifacts + env: + GH_TOKEN: ${{ github.token }} + RUN_ID: ${{ github.event.workflow_run.id }} + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} + HEAD_REPOSITORY: ${{ github.event.workflow_run.head_repository.full_name }} + run: | + set -euo pipefail + artifacts="$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts")" + head_owner="${HEAD_REPOSITORY%%/*}" + pr_number="$(gh api "repos/$GITHUB_REPOSITORY/pulls?state=open&head=$head_owner:$HEAD_BRANCH" --jq '.[0].number // empty')" + [ -n "$pr_number" ] || exit 0 + + message="## CI build artifacts" + found=0 + while IFS='|' read -r platform artifact_name artifact_file; do + artifact_id="$(printf '%s' "$artifacts" | jq -r --arg name "$artifact_name" '[.artifacts[] | select(.name == $name) | .id][0] // empty')" + if [ -n "$artifact_id" ] && [ "$artifact_id" != null ]; then + artifact_url="https://github.com/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts/$artifact_id" + message+=$'\n'"- **$platform**: [$artifact_file]($artifact_url)" + found=1 + fi + done <<'ARTIFACTS' + macOS|gen1recomp++-macos|gen1recomp++-macos.zip + iOS|gen1recomp++-ios-ipa|gen1recomp++.ipa + Nintendo Switch|gen1recomp-switch-nro|gen1recomp-switch.nro + Xbox UWP|gen1recomp-xbox-uwp|gen1recomp-xbox-uwp.zip + Linux arm64|gen1recomp-linux-arm64|gen1recomp-linux-arm64.AppImage + ARTIFACTS + + [ "$found" -eq 1 ] || exit 0 + commit_hash="$(printf '%s' "${{ github.event.workflow_run.head_sha }}" | cut -c1-7)" + build_time="$(date -u "+%Y-%m-%d %H:%M:%S UTC")" + message+=$'\n\n'"**Commit**: [#$commit_hash](https://github.com/$HEAD_REPOSITORY/commit/${{ github.event.workflow_run.head_sha }})" + message+=$'\n'"**Build Time**: \`$build_time\`" + message+=$'\n\n'"This comment was automatically generated. [View workflow run](https://github.com/$GITHUB_REPOSITORY/actions/runs/$RUN_ID)" + + echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT" + { + echo 'message<> "$GITHUB_OUTPUT" + - name: comment platform artifacts + if: steps.artifacts.outputs.pr_number != '' + uses: thollander/actions-comment-pull-request@v3 + with: + message: ${{ steps.artifacts.outputs.message }} + pr-number: ${{ steps.artifacts.outputs.pr_number }} + comment-tag: platform-build-result + github-token: ${{ github.token }} diff --git a/.github/workflows/switch-artifact-comment.yml b/.github/workflows/switch-artifact-comment.yml deleted file mode 100644 index 286f2f62..00000000 --- a/.github/workflows/switch-artifact-comment.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Switch artifact comment - -on: - workflow_run: - workflows: [ci] - types: [completed] - -permissions: - contents: read - issues: write - pull-requests: write - -jobs: - comment: - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' - runs-on: ubuntu-latest - steps: - - id: artifact - env: - GH_TOKEN: ${{ github.token }} - RUN_ID: ${{ github.event.workflow_run.id }} - HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} - HEAD_REPOSITORY: ${{ github.event.workflow_run.head_repository.full_name }} - run: | - artifact_id="$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts" --jq '.artifacts[] | select(.name == "gen1recomp-switch-nro") | .id')" - [ -n "$artifact_id" ] || exit 0 - head_owner="${HEAD_REPOSITORY%%/*}" - pr_number="$(gh api "repos/$GITHUB_REPOSITORY/pulls?state=open&head=$head_owner:$HEAD_BRANCH" --jq '.[0].number // empty')" - [ -n "$pr_number" ] || exit 0 - echo "artifact_url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/artifacts/$artifact_id" >> "$GITHUB_OUTPUT" - echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT" - # Upsert via comment-tag only — do not delete-all bot comments (clobbers iOS). - - name: Get build info - id: build-info - env: - HEAD_SHA: ${{ github.event.workflow_run.head_sha }} - run: | - commit_hash="$(printf '%s' "$HEAD_SHA" | cut -c1-7)" - build_time="$(date "+%Y-%m-%d %H:%M:%S")" - echo "hash=$commit_hash" >> "$GITHUB_OUTPUT" - echo "time=$build_time" >> "$GITHUB_OUTPUT" - - name: comment Switch artifact - if: steps.artifact.outputs.pr_number != '' - uses: thollander/actions-comment-pull-request@v3 - with: - message: | - [gen1recomp-switch.nro](${{ steps.artifact.outputs.artifact_url }}) - - **Commit**: [#${{ steps.build-info.outputs.hash }}](https://github.com/${{ github.event.workflow_run.head_repository.full_name }}/commit/${{ github.event.workflow_run.head_sha }}) - **Build Time**: `${{ steps.build-info.outputs.time }}` - - This comment was automatically generated. [View workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}) - pr-number: ${{ steps.artifact.outputs.pr_number }} - comment-tag: switch-build-result - github-token: ${{ github.token }}