{
  "name": "jump-section: Hermes Fix Callback",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "hermes-fix-callback",
        "responseMode": "onReceived",
        "responseData": "noData"
      },
      "id": "webhook-callback",
      "name": "Webhook: Hermes Fix Callback",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1.1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// n8n->Hermes \ubc29\ud5a5(HERMES_WEBHOOK_SECRET)\uacfc\ub294 \ubcc4\ub3c4\uc758 \uc2dc\ud06c\ub9bf\uc73c\ub85c \uac80\uc99d\ud55c\ub2e4.\nconst item = $input.first().json;\nconst body = item.body || item;\nconst providedSecret = (item.headers && item.headers['x-hermes-callback-secret']) || '';\n\nif (providedSecret !== $env.HERMES_CALLBACK_SECRET) {\n  // \uc2dc\ud06c\ub9bf \ubd88\uc77c\uce58 - \uc870\uc6a9\ud788 \ud3d0\uae30\ud55c\ub2e4 (\uac00\uc9dc \uc131\uacf5 \ucf5c\ubc31\uc73c\ub85c \uc624\ud0d0 \ubc18\uc751\uc774 \ub2ec\ub9ac\ub294 \uac83\uc744 \ubc29\uc9c0)\n  return [];\n}\n\nreturn [{ json: body }];"
      },
      "id": "verify-callback-secret",
      "name": "\ucf5c\ubc31 \uc2dc\ud06c\ub9bf \uac80\uc99d",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const data = $input.first().json;\n\nlet content = null;\nif (data.status === 'success') content = 'rocket';\nelse if (data.status === 'error') content = '-1';\n// no_changes\ub294 \uc2ac\ub798\uc2dc \ucee4\ub9e8\ub4dc\uc758 \uc6d0\ub798 \ub3d9\uc791\uacfc \ub3d9\uc77c\ud558\uac8c \ucd94\uac00 \ubc18\uc751 \uc5c6\uc774 \uc870\uc6a9\ud788 \uc885\ub8cc\ud55c\ub2e4.\n\nif (!content) return [];\n\nreturn [{\n  json: {\n    ...data,\n    reactionContent: content,\n    // command\uac00 'fix'\uc774\uba74 \ub9ac\ubdf0 \ucf54\uba58\ud2b8 \ub2f5\uc7a5(/fix), \uadf8 \uc678(fix-build/fix-lint)\ub294 \uc77c\ubc18 PR \ucf54\uba58\ud2b8\ub2e4.\n    isReviewComment: data.command === 'fix'\n  }\n}];"
      },
      "id": "status-to-reaction",
      "name": "\uc0c1\ud0dc -> \ubc18\uc751 \ub9e4\ud551",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "id": "is-review",
              "leftValue": "={{ $json.isReviewComment }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ]
        }
      },
      "id": "if-review-comment",
      "name": "IF: \ub9ac\ubdf0 \ucf54\uba58\ud2b8?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.github.com/repos/{{ $json.repo.owner }}/{{ $json.repo.name }}/pulls/comments/{{ $json.comment.id }}/reactions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/vnd.github+json"
            },
            {
              "name": "X-GitHub-Api-Version",
              "value": "2022-11-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $env.GITHUB_TOKEN }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { content: $json.reactionContent } }}",
        "options": {}
      },
      "id": "react-review-comment",
      "name": "GitHub: \ub9ac\ubdf0 \ucf54\uba58\ud2b8 \ubc18\uc751",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        200
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.github.com/repos/{{ $json.repo.owner }}/{{ $json.repo.name }}/issues/comments/{{ $json.comment.id }}/reactions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/vnd.github+json"
            },
            {
              "name": "X-GitHub-Api-Version",
              "value": "2022-11-28"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $env.GITHUB_TOKEN }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { content: $json.reactionContent } }}",
        "options": {}
      },
      "id": "react-issue-comment",
      "name": "GitHub: PR \ucf54\uba58\ud2b8 \ubc18\uc751",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        400
      ]
    }
  ],
  "connections": {
    "Webhook: Hermes Fix Callback": {
      "main": [
        [
          {
            "node": "\ucf5c\ubc31 \uc2dc\ud06c\ub9bf \uac80\uc99d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ucf5c\ubc31 \uc2dc\ud06c\ub9bf \uac80\uc99d": {
      "main": [
        [
          {
            "node": "\uc0c1\ud0dc -> \ubc18\uc751 \ub9e4\ud551",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\uc0c1\ud0dc -> \ubc18\uc751 \ub9e4\ud551": {
      "main": [
        [
          {
            "node": "IF: \ub9ac\ubdf0 \ucf54\uba58\ud2b8?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF: \ub9ac\ubdf0 \ucf54\uba58\ud2b8?": {
      "main": [
        [
          {
            "node": "GitHub: \ub9ac\ubdf0 \ucf54\uba58\ud2b8 \ubc18\uc751",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "GitHub: PR \ucf54\uba58\ud2b8 \ubc18\uc751",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "jump-section"
    },
    {
      "name": "comment-fix"
    },
    {
      "name": "hermes"
    }
  ]
}