Welcome to mirror list, hosted at ThFree Co, Russian Federation.

benchmark.yml « workflows « .github - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1d8e3455c25e38f73c012d6942da992a2bc492c3 (plain)
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
73
74
75
76
77
78
79
80
81
name: Benchmark - CLI

on:
  pull_request:
    branches:
      - '*'
  issue_comment:
    types:
      - created
      - edited

jobs:
  pull-request:
    runs-on: ubuntu-latest
    steps:
      - name: Incoming Pull Request
        if: |
          github.event_name == 'pull_request' || (
            github.event_name == 'issue_comment' &&
            github.event.issue.pull_request &&
            startsWith(github.event.comment.body, 'test this please ✅')
          )
        env:
          # gh cli uses these env vars for owner/repo/token
          GH_REPO: "npm/benchmarks"
          GITHUB_TOKEN: ${{ secrets.NPM_BENCHMARKS_TOKEN }}
        run: |
          if [[ "$GITHUB_TOKEN" == "" ]]; then
            echo "No auth - from fork pull request, exiting"
            exit 0
          fi

          EVENT_NAME="${{ github.event_name }}"
          OWNER="${{ github.event.repository.owner.login }}"
          REPO="${{ github.event.repository.name }}"
          PR=""

          if [[ "$EVENT_NAME" == "pull_request" ]]; then
            PR="${{ github.event.pull_request.number }}"
          else
            PR="${{ github.event.issue.number }}"
          fi

          EVENT="${EVENT_NAME} ${OWNER}/${REPO}#${PR}"
          echo '{
            "event_type": "'"$EVENT"'",
            "client_payload": {
              "pr_id": "'"$PR"'",
              "repo": "'"$REPO"'",
              "owner": "'"$OWNER"'"
            }
          }' | gh api repos/{owner}/{repo}/dispatches --input -

  comment:
    runs-on: ubuntu-latest
    steps:
      - name: Incoming Comment
        if: |
          github.event_name == 'issue_comment' &&
          github.event.issue.pull_request &&
          startsWith(github.event.comment.body, 'test this please ✅')
        env:
          # gh cli uses this env var as the token
          GITHUB_TOKEN: ${{ secrets.NPM_BENCHMARKS_TOKEN }}
        run: |
          COMMENT_NODE_ID="${{ github.event.comment.node_id }}"
          QUERY='mutation ($inputData:AddReactionInput!) {
            addReaction (input:$inputData) {
              reaction { content }
            }
          }'
          echo '{
            "query": "'${QUERY}'",
            "variables": {
              "inputData": {
                "subjectId": "'"${COMMENT_NODE_ID}"'",
                "content": "ROCKET"
              }
            }
          }' | gh api graphql --input -