{
  "name": "10 - Run Playwright Suite",
  "nodes": [
    {
      "parameters": {
        "content": "## 10 Run Playwright Suite\nWe have: a GitHub repo with Playwright tests.\nWe get: the run result (success or failure) and its link.\n\n1. Add the workflow_dispatch YAML from the tutorial page to your repo.\n2. Fill Run Config. Add a GitHub credential to both HTTP nodes.\nThe loop checks every 30 seconds, at most 20 times.",
        "height": 220,
        "width": 480
      },
      "id": "10000000-0000-4000-8000-000000000000",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -280
      ]
    },
    {
      "parameters": {},
      "id": "10000000-0000-4000-8000-000000000001",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "66dbb700-8ad6-5133-90f1-eaf4592c010a",
              "name": "owner",
              "value": "YOUR-GITHUB-USER",
              "type": "string"
            },
            {
              "id": "07c84a43-9cb0-5e3f-b4b4-2ef1e3af3053",
              "name": "repo",
              "value": "ttacart-playwright",
              "type": "string"
            },
            {
              "id": "fa41d366-cf47-5af1-9604-ec839dcf391e",
              "name": "workflow",
              "value": "playwright.yml",
              "type": "string"
            },
            {
              "id": "4369e4f1-a4b7-55cd-b436-c713106f0807",
              "name": "ref",
              "value": "main",
              "type": "string"
            },
            {
              "id": "caa410ab-8535-5aff-9a63-ebcd0e6f39d3",
              "name": "grep",
              "value": "",
              "type": "string"
            },
            {
              "id": "8d8c3167-6e68-5e99-a744-58f407f3aab7",
              "name": "since",
              "value": "={{ $now.toUTC().minus({ minutes: 1 }).toFormat(\"yyyy-MM-dd'T'HH:mm:ss'Z'\") }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "10000000-0000-4000-8000-000000000002",
      "name": "Run Config",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        200,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.github.com/repos/{{ $('Run Config').first().json.owner }}/{{ $('Run Config').first().json.repo }}/actions/workflows/{{ $('Run Config').first().json.workflow }}/dispatches",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "githubApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/vnd.github+json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ ref: $json.ref, inputs: { grep: $json.grep } }) }}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "id": "10000000-0000-4000-8000-000000000003",
      "name": "Run Suite",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        400,
        0
      ]
    },
    {
      "parameters": {
        "amount": 30,
        "unit": "seconds"
      },
      "id": "10000000-0000-4000-8000-000000000004",
      "name": "Wait 30s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        600,
        0
      ],
      "webhookId": "0b2c3d4e-1010-4a2b-9c3d-7e8f9a0b1c10"
    },
    {
      "parameters": {
        "url": "=https://api.github.com/repos/{{ $('Run Config').first().json.owner }}/{{ $('Run Config').first().json.repo }}/actions/workflows/{{ $('Run Config').first().json.workflow }}/runs",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "githubApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/vnd.github+json"
            }
          ]
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "event",
              "value": "workflow_dispatch"
            },
            {
              "name": "created",
              "value": "=>={{ $('Run Config').first().json.since }}"
            },
            {
              "name": "per_page",
              "value": "1"
            }
          ]
        },
        "options": {}
      },
      "id": "10000000-0000-4000-8000-000000000005",
      "name": "Get Run",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        800,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "6ab45d4e-4c71-5354-8d89-7cbcea92cd87",
              "leftValue": "={{ (($json.workflow_runs || [])[0] || {}).status }}",
              "rightValue": "completed",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "b563fafd-b15a-535f-9425-df7fe56545fe",
              "leftValue": "={{ $runIndex }}",
              "rightValue": 20,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "10000000-0000-4000-8000-000000000006",
      "name": "Done?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1000,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "612d3486-1bc6-5d39-becb-8480cfe22d10",
              "name": "conclusion",
              "value": "={{ (($json.workflow_runs || [])[0] || {}).conclusion || 'still running' }}",
              "type": "string"
            },
            {
              "id": "6c14d81a-ad1b-55a2-bb89-0680cbc38bfd",
              "name": "url",
              "value": "={{ (($json.workflow_runs || [])[0] || {}).html_url || '' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "10000000-0000-4000-8000-000000000007",
      "name": "Result",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1220,
        -80
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Run Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Config": {
      "main": [
        [
          {
            "node": "Run Suite",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Suite": {
      "main": [
        [
          {
            "node": "Wait 30s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 30s": {
      "main": [
        [
          {
            "node": "Get Run",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Run": {
      "main": [
        [
          {
            "node": "Done?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Done?": {
      "main": [
        [
          {
            "node": "Result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 30s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "active": false
}
