File: comment.yml

package info (click to toggle)
mpv 0.40.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,676 kB
  • sloc: ansic: 152,062; python: 1,228; sh: 646; javascript: 612; cpp: 461; objc: 302; pascal: 49; xml: 29; makefile: 19
file content (46 lines) | stat: -rw-r--r-- 1,791 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: comment

on:
  workflow_run:
    workflows: [build]
    types: [completed]

jobs:
  pr_comment:
    if: github.event.workflow_run.event == 'pull_request' &&
        github.event.workflow_run.conclusion == 'success'
    runs-on: ubuntu-latest
    steps:
      - env:
          GH_REPO: ${{ github.repository }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          pr=$(gh pr list --state open --json headRefOid,number \
            --jq '.[] | select(.headRefOid == "${{ github.event.workflow_run.head_sha }}") | .number')
          if [ -z "$pr" ]; then
            echo "No matching open pull request found"
            exit 0
          fi

          artifacts=$(gh api repos/{owner}/{repo}/actions/runs/${{ github.event.workflow_run.id }}/artifacts --jq '.artifacts')
          if [ "$(echo "$artifacts" | jq 'length')" -eq 0 ]; then
            echo "No artifacts found"
            exit 0
          fi

          body=$(echo "$artifacts" | jq -r '
            def link: "https://nightly.link/${{ github.repository }}/actions/artifacts/\(.id).zip";
            def entry: "* [\(.name)](\(link))";
            "Download the artifacts for this pull request:\n<details><summary>Windows</summary>\n\n" +
            (sort_by(.name) | map(select(.name | test("w64|msvc")) | entry) | join("\n")) +
            "\n</details>\n<details><summary>macOS</summary>\n\n" +
            (sort_by(.name) | map(select(.name | test("macos")) | entry) | join("\n")) +
            "\n</details>"
          ')

          comment_id=$(gh issue view $pr --json comments \
            --jq '.comments[] | select(.author.login == "github-actions") | .id')
          if [ -n "$comment_id" ]; then
            edit=--edit-last
          fi
          gh pr comment $pr --body "$body" $edit