๐Ÿ“ฆ hexojs / hexo

๐Ÿ“„ commenter.yml ยท 73 lines
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73name: Commenter

on:
  pull_request_target:

  workflow_run:
    workflows: ["Benchmark"]
    types:
      - completed

permissions:
  contents: read

jobs:
  comment-test:
    name: How to test
    permissions:
      pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment
    runs-on: ubuntu-latest
    if: ${{github.event_name == 'pull_request_target'}}
    steps:
      - name: Comment PR - How to test
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          header: How to test
          message: |
            ## How to test

            ```sh
            git clone -b ${{ github.head_ref }} https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
            cd hexo
            npm install
            npm test
            ```

  comment-flamegraph:
    name: Flamegraph
    permissions:
      pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment
      actions: read # get artifact
    runs-on: ubuntu-latest
    if: ${{github.event_name == 'workflow_run' && github.event.workflow_run.conclusion=='success'}}
    env:
      comment_result: ".tmp-comment-flamegraph.md"
    steps:
      - name: download artifact
        uses: actions/download-artifact@v7
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          run-id: ${{toJSON(github.event.workflow_run.id)}}
          pattern: "comment-*"
          merge-multiple: true

      - name: get PR number
        run: |
          echo "pr_number=$(cat .tmp-comment-pr_number)" >> "$GITHUB_ENV"

      - name: combime comment
        if: ${{env.pr_number!=''}}
        run: |
          echo "## Flamegraph" > ${{env.comment_result}}
          echo "" >> ${{env.comment_result}}
          cat .tmp-comment-flamegraph-*.md >> ${{env.comment_result}}

      - name: Comment PR - flamegraph
        if: ${{env.pr_number!=''}}
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
          number: ${{env.pr_number}}
          header: Flamegraph
          path: ${{env.comment_result}}