{
  "id": "btO7TntrjfhwAxeT",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Smart Dependency Update Tracker",
  "tags": [],
  "nodes": [
    {
      "id": "0a705640-223f-40dd-a661-3c34f608fd7f",
      "name": "Check Same Version",
      "type": "n8n-nodes-base.code",
      "position": [
        -1904,
        -240
      ],
      "parameters": {
        "jsCode": "return items.map(item => {\n  const { dependency, current, latest } = item.json;\n\n  return {\n    json: {\n      dependency,\n      current,\n      latest,\n      same: current === latest,   // true if same\n      major: item.json.critical   // keep your old major detection\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "eeb2f53b-9ae5-4e12-a7a5-237e6c95ba34",
      "name": "If same Version",
      "type": "n8n-nodes-base.if",
      "position": [
        -1744,
        -240
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1cecbda6-929e-4e2f-acc8-024429c6a64f",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{$json.same}}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9ea87c06-bafd-4576-9544-3b3fc542c8c3",
      "name": "Run Gradle Dependency Check",
      "type": "n8n-nodes-base.ssh",
      "position": [
        -2464,
        -240
      ],
      "parameters": {
        "cwd": "/home/user/Documents/andorid/project/AndroidBoilerplate/",
        "command": "./gradlew dependencyUpdates"
      },
      "credentials": {
        "sshPassword": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e22ad97d-cdb3-45b9-9afb-46c67f5c8a1a",
      "name": "Extract Dependency Updates",
      "type": "n8n-nodes-base.code",
      "position": [
        -2256,
        -240
      ],
      "parameters": {
        "jsCode": "const stdout = $json[\"stdout\"];\nconst lines = stdout.split(\"\\n\");\n\nconst updates = [];\nlet section = null;\n\nfor (let line of lines) {\n\tline = line.trim();\n\n\t// enter update section\n\tif (line.startsWith(\"The following dependencies have later milestone versions:\")) {\n\t\tsection = \"updates\";\n\t\tcontinue;\n\t}\n\n\t// stop at next section\n\tif (section === \"updates\" && line.startsWith(\"Gradle release-candidate updates:\")) {\n\t\tsection = null;\n\t}\n\n\t// capture dependencies with version change\n\tif (section === \"updates\" && line.startsWith(\"-\")) {\n\t\tconst match = line.match(/- (.*?) \\[(.*?) -> (.*?)\\]/);\n\t\tif (match) {\n\t\t\tupdates.push({\n\t\t\t\tdependency: match[1],\n\t\t\t\tcurrent: match[2],\n\t\t\t\tlatest: match[3]\n\t\t\t});\n\t\t}\n\t}\n}\n\nreturn updates.map(dep => ({ json: dep }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "b23738bf-99d4-4d18-bd42-31923be36cd0",
      "name": "Mark Major Updates",
      "type": "n8n-nodes-base.code",
      "position": [
        -2080,
        -240
      ],
      "parameters": {
        "jsCode": "function isMajorUpdate(current, latest) {\n\tconst parse = (v) => v.replace(/[^\\d.]/g, \"\").split(\".\").map(n => parseInt(n || \"0\", 10));\n\tconst [cMajor] = parse(current);\n\tconst [lMajor] = parse(latest);\n\treturn lMajor > cMajor;\n}\n\nreturn items.map(item => {\n\tconst { dependency, current, latest } = item.json;\n\treturn {\n\t\tjson: {\n\t\t\tdependency,\n\t\t\tcurrent,\n\t\t\tlatest,\n\t\t\tcritical: isMajorUpdate(current, latest)\n\t\t}\n\t};\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "771c01dd-92f1-416b-a456-416598f6ed7b",
      "name": "Filter Major Updates",
      "type": "n8n-nodes-base.code",
      "position": [
        -1424,
        -64
      ],
      "parameters": {
        "jsCode": "return items.filter(i => i.json.critical === true);\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2591323f-1858-4922-a487-21221dbbdbee",
      "name": "Update build.gradle",
      "type": "n8n-nodes-base.ssh",
      "position": [
        -1232,
        -64
      ],
      "parameters": {
        "cwd": "/home/user/Documents/andorid/project/AndroidBoilerplate/",
        "command": "=sed -i \"/{{ $json.dependency }}/s/{{ $json.current }}/{{ $json.latest }}/\" app/build.gradle\n"
      },
      "credentials": {
        "sshPassword": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "28998fbb-3c67-40a6-b54c-31a837bcbe82",
      "name": "Notify: Dependency Updated",
      "type": "n8n-nodes-base.slack",
      "position": [
        -1056,
        -64
      ],
      "parameters": {
        "text": "Dependency {{$json.dependency}} has been updated successfully.\nOld version: {{$json.current}}\nNew version: {{$json.latest}}\n",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09S57E2JQ2",
          "cachedResultName": "n8n"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "1f45928d-cc2d-4d98-acbc-45918b5ce66c",
      "name": "Trigger Workflow Monthly",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2704,
        -240
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "daysInterval": 30,
              "triggerAtHour": 10,
              "triggerAtMinute": 30
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d080eba8-b5b8-41de-83fa-b59fd506331e",
      "name": "Notify: Dependency Up-to-date",
      "type": "n8n-nodes-base.slack",
      "position": [
        -1456,
        -464
      ],
      "parameters": {
        "text": "=No update needed \u2014 {{$json.dependency}} is already latest ({{$json.current}})\n",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09S57E2JQ2",
          "cachedResultName": "n8n"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "49216e1d-6213-4c42-bb49-2a6a95814ff4",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2784,
        -368
      ],
      "parameters": {
        "color": 7,
        "height": 304,
        "content": "## Trigger Workflow\n**The workflow starts on a schedule you choose (like a daily reminder).** \n"
      },
      "typeVersion": 1
    },
    {
      "id": "5a0229d9-3465-4e30-a07d-919cf2c5d066",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1536,
        -272
      ],
      "parameters": {
        "color": 7,
        "width": 736,
        "height": 368,
        "content": "## Apply Dependency and Status Update\n\n**Filter Major Updates** :This node filters out only the major updates that need to be applied to your project. Minor updates are ignored here.\n**Update build.gradle** : This node automatically updates the build.gradle file with the latest versions of the major dependencies. No manual editing needed. Makes sure your app uses the latest versions\n**Notify: Dependency Updated** : Shares an update summary\u2014including which libraries were updated\u2014straight to your team\u2019s Slack channel, so everyone is kept in the loop\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ce1f7c51-e5c2-4568-b50c-cef13c2d4697",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2528,
        -368
      ],
      "parameters": {
        "color": 7,
        "width": 944,
        "height": 304,
        "content": "## Dependency Update Detection\nThis workflow section automatically checks your project\u2019s libraries for available updates. It identifies major version changes, compares current and latest versions, and determines whether a library needs updating. Outdated dependencies are flagged for further action, while up-to-date libraries are skipped.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7a3703cd-77f1-42fb-99fc-d26b0ca9d703",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1536,
        -592
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 304,
        "content": "## Notify: Dependency Uptodate\nSends a Slack message for libraries that are already up-to-date, so your team knows nothing needs to be done."
      },
      "typeVersion": 1
    },
    {
      "id": "dad20b56-55f6-4bd7-bf9c-33333452a3bc",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3456,
        -768
      ],
      "parameters": {
        "width": 448,
        "height": 560,
        "content": "## How it Works\nThis workflow automatically checks your project\u2019s libraries for updates. It runs a Gradle command to list outdated dependencies, identifies major version changes, and compares current versus latest versions. Libraries that are already up-to-date are skipped, while outdated ones are flagged. Major updates can automatically modify your build.gradle file, and Slack messages notify your team about which dependencies were updated or already up-to-date. This ensures your project stays current without manual tracking.\n\n## Setup Steps\n**1.** Connect an SSH account to access your project folder.\n\n**2.** Configure the schedule trigger (e.g., every 30 days at 10:30 AM).\n\n**3.** Set up Slack credentials and select the channel for notifications.\n\n**4.** Confirm the workflow nodes are linked in this order: Run Gradle \u2192 Extract Updates \u2192 Mark Major \u2192 Check Version \u2192 Conditional \u2192 Update Gradle / Notify Slack.\n\n**5.** Activate the workflow to run automatically and start receiving update notifications."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8ea9f4fd-1bb9-460a-a4b1-ccbd176946fc",
  "connections": {
    "If same Version": {
      "main": [
        [
          {
            "node": "Notify: Dependency Up-to-date",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Filter Major Updates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Same Version": {
      "main": [
        [
          {
            "node": "If same Version",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark Major Updates": {
      "main": [
        [
          {
            "node": "Check Same Version",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update build.gradle": {
      "main": [
        [
          {
            "node": "Notify: Dependency Updated",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Major Updates": {
      "main": [
        [
          {
            "node": "Update build.gradle",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger Workflow Monthly": {
      "main": [
        [
          {
            "node": "Run Gradle Dependency Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Dependency Updates": {
      "main": [
        [
          {
            "node": "Mark Major Updates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Gradle Dependency Check": {
      "main": [
        [
          {
            "node": "Extract Dependency Updates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}