Sauvegarde automatique des flux de travail et des identifiants sur GitHub (avec détection des modifications)

Avancé

Ceci est unDevOpsworkflow d'automatisation du domainecontenant 21 nœuds.Utilise principalement des nœuds comme If, Set, Crypto, Github, ReadWriteFile. Sauvegarde automatique des workflows et des informations d'identification sur GitHub (avec détection de modifications)

Prérequis
  • Personal Access Token GitHub

Catégorie

Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "meta": {
    "instanceId": "558d88703fb65b2d0e44613bc35916258b0f0bf983c5d4730c00c424b77ca36a"
  },
  "nodes": [
    {
      "id": "6f0fcaed-fd41-4ac4-816d-41098539f42a",
      "name": "Déclencheur planifié",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1900,
        -180
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1211ee7a-03d1-4a00-9759-bc0402d3686c",
      "name": "Obtenir le nouveau hachage de workflow",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -1020,
        -280
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "U7Jh9njKLEjGLVIl",
          "cachedResultName": "n8n Backup Changes"
        },
        "workflowInputs": {
          "value": {
            "filePath": "={{ $('Set Workflow Path').item.json.filePath }}"
          },
          "schema": [
            {
              "id": "filePath",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "filePath",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "filePath"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2,
      "alwaysOutputData": false
    },
    {
      "id": "d655d400-d743-4dd8-8b05-12701c8c4f9d",
      "name": "Obtenir l'ancien hachage de workflow",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -1460,
        -280
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "U7Jh9njKLEjGLVIl",
          "cachedResultName": "n8n Backup Changes"
        },
        "workflowInputs": {
          "value": {
            "filePath": "={{ $('Set Workflow Path').item.json.filePath }}"
          },
          "schema": [
            {
              "id": "filePath",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "filePath",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "filePath"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0d13634a-f74a-4194-8a54-9531205d0883",
      "name": "Lire les données du workflow",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -580,
        -280
      ],
      "parameters": {
        "options": {},
        "fileSelector": "={{ $('Set Workflow Path').item.json.filePath }}"
      },
      "typeVersion": 1
    },
    {
      "id": "cfa7d2e0-e63d-4392-899d-13fd2b587a15",
      "name": "Définir le chemin du workflow",
      "type": "n8n-nodes-base.set",
      "position": [
        -1680,
        -280
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c60cce2a-609d-417e-a73c-9719a490cc85",
              "name": "filePath",
              "type": "string",
              "value": "/data/shared/WorkFlowBackup.json"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5b5250ed-c3de-431f-8e4b-c8b6a6352393",
      "name": "Exécuter la sauvegarde du workflow",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        -1240,
        -280
      ],
      "parameters": {
        "command": "=n8n export:workflow --all --output={{ $('Set Workflow Path').item.json.filePath }}"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "510d346d-2eec-4839-aa99-6d61cc00573a",
      "name": "Lire le fichier",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -1680,
        -540
      ],
      "parameters": {
        "options": {},
        "fileSelector": "={{ $json.filePath }}"
      },
      "typeVersion": 1
    },
    {
      "id": "9ce2b61a-d4cd-46f5-a20b-02cbb864c259",
      "name": "Extraire les données",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1460,
        -540
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "381e022a-f265-4a07-9a49-27f401cc08d3",
      "name": "Hacher les données",
      "type": "n8n-nodes-base.crypto",
      "position": [
        -1240,
        -540
      ],
      "parameters": {
        "type": "SHA256",
        "value": "={{$json.data}}",
        "dataPropertyName": "hash"
      },
      "typeVersion": 1
    },
    {
      "id": "73d5f6a5-a4ee-49f9-ba5f-2646887daf9b",
      "name": "Générateur de hachage",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -1900,
        -540
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "filePath"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "78bd1ed8-0c19-4106-ab84-1d25f0f4b806",
      "name": "Extraire les données du workflow",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -360,
        -280
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "740fd3e5-f356-436c-ad2b-86da10fb346d",
      "name": "GitHub Sauvegarde du workflow",
      "type": "n8n-nodes-base.github",
      "onError": "continueRegularOutput",
      "position": [
        -140,
        -280
      ],
      "webhookId": "ccf2ad35-62aa-4e3e-9811-ea6d7fca0aba",
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "list",
          "value": "nickmehr-hamed",
          "cachedResultUrl": "https://github.com/nickmehr-hamed",
          "cachedResultName": "nickmehr-hamed"
        },
        "filePath": "={{ \"backups/WorkFlow Backup \" + new Date($now).toISOString().replace('T', ' ').slice(0, 16) + \".json\" }}",
        "resource": "file",
        "repository": {
          "__rl": true,
          "mode": "url",
          "value": "https://github.com/nickmehr-hamed/n8n"
        },
        "fileContent": "={{ $json.data }}",
        "commitMessage": "={{ \"WorkFlow Backup \" + new Date($now).toISOString().replace('T', ' ').slice(0, 16) }}"
      },
      "credentials": {
        "githubApi": {
          "id": "4ZsFUnBi2lfVYEHW",
          "name": "GitHub account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "dc2e73a2-36d8-4d92-947f-b3d01fac934d",
      "name": "Obtenir le nouveau hachage d'identifiants",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -1020,
        -80
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "U7Jh9njKLEjGLVIl",
          "cachedResultName": "n8n Backup Changes"
        },
        "workflowInputs": {
          "value": {
            "filePath": "={{ $('Set Credential Path').item.json.filePath }}"
          },
          "schema": [
            {
              "id": "filePath",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "filePath",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "filePath"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2,
      "alwaysOutputData": false
    },
    {
      "id": "b5512300-5bb4-4781-9d5b-3b61a90d7220",
      "name": "Obtenir l'ancien hachage d'identifiants",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -1460,
        -80
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "U7Jh9njKLEjGLVIl",
          "cachedResultName": "n8n Backup Changes"
        },
        "workflowInputs": {
          "value": {
            "filePath": "={{ $('Set Credential Path').item.json.filePath }}"
          },
          "schema": [
            {
              "id": "filePath",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "filePath",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "filePath"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ef1807a5-8d7c-4d05-b819-a433d495ca36",
      "name": "Lire les données d'identifiants",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -580,
        -80
      ],
      "parameters": {
        "options": {},
        "fileSelector": "={{ $('Set Credential Path').item.json.filePath }}"
      },
      "typeVersion": 1
    },
    {
      "id": "ceaa31cb-bfff-43b6-9433-7d1e124d6d86",
      "name": "Définir le chemin des identifiants",
      "type": "n8n-nodes-base.set",
      "position": [
        -1680,
        -80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c60cce2a-609d-417e-a73c-9719a490cc85",
              "name": "filePath",
              "type": "string",
              "value": "/data/shared/CredentialBackup.json"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "babf93ca-cd95-4a38-9ecc-c16ffbd48dc0",
      "name": "Exécuter la sauvegarde des identifiants",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        -1240,
        -80
      ],
      "parameters": {
        "command": "=n8n export:credentials --all --output={{ $('Set Credential Path').item.json.filePath }}"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "d2c8c228-d276-44f7-831b-611d05610e8f",
      "name": "Extraire les données d'identifiants",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -360,
        -80
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "1f94c09d-26aa-444b-b607-1366b7ffc4d0",
      "name": "GitHub Sauvegarde des identifiants",
      "type": "n8n-nodes-base.github",
      "onError": "continueRegularOutput",
      "position": [
        -140,
        -80
      ],
      "webhookId": "ccf2ad35-62aa-4e3e-9811-ea6d7fca0aba",
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "list",
          "value": "nickmehr-hamed",
          "cachedResultUrl": "https://github.com/nickmehr-hamed",
          "cachedResultName": "nickmehr-hamed"
        },
        "filePath": "={{ \"backups/ Credential Backup \" + new Date($now).toISOString().replace('T', ' ').slice(0, 16) + \".json\" }}",
        "resource": "file",
        "repository": {
          "__rl": true,
          "mode": "url",
          "value": "https://github.com/nickmehr-hamed/n8n"
        },
        "fileContent": "={{ $json.data }}",
        "commitMessage": "={{ \" Credential Backup \" + new Date($today).toISOString().replace('T', ' ').slice(0, 16) }}"
      },
      "credentials": {
        "githubApi": {
          "id": "4ZsFUnBi2lfVYEHW",
          "name": "GitHub account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "a1a606b2-a0d7-4d9c-98b1-4657b902fccd",
      "name": "Si workflow mis à jour",
      "type": "n8n-nodes-base.if",
      "position": [
        -800,
        -280
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c028ce1d-3fe9-4dc9-a3e9-296460e12c83",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $('Get New Workflow Hash').item.json.hash }}",
              "rightValue": "={{ $('Get Old Workflow Hash').item.json.hash }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a6809c8d-ccd9-4acf-9854-b6a36e74c439",
      "name": "Si identifiants mis à jour",
      "type": "n8n-nodes-base.if",
      "position": [
        -800,
        -80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c028ce1d-3fe9-4dc9-a3e9-296460e12c83",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $('Get New Credential Hash').item.json.hash }}",
              "rightValue": "={{ $('Get Old Credential Hash').item.json.hash }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    }
  ],
  "pinData": {},
  "connections": {
    "381e022a-f265-4a07-9a49-27f401cc08d3": {
      "main": [
        []
      ]
    },
    "510d346d-2eec-4839-aa99-6d61cc00573a": {
      "main": [
        [
          {
            "node": "9ce2b61a-d4cd-46f5-a20b-02cbb864c259",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "73d5f6a5-a4ee-49f9-ba5f-2646887daf9b": {
      "main": [
        [
          {
            "node": "510d346d-2eec-4839-aa99-6d61cc00573a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9ce2b61a-d4cd-46f5-a20b-02cbb864c259": {
      "main": [
        [
          {
            "node": "381e022a-f265-4a07-9a49-27f401cc08d3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6f0fcaed-fd41-4ac4-816d-41098539f42a": {
      "main": [
        [
          {
            "node": "cfa7d2e0-e63d-4392-899d-13fd2b587a15",
            "type": "main",
            "index": 0
          },
          {
            "node": "ceaa31cb-bfff-43b6-9433-7d1e124d6d86",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cfa7d2e0-e63d-4392-899d-13fd2b587a15": {
      "main": [
        [
          {
            "node": "d655d400-d743-4dd8-8b05-12701c8c4f9d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0d13634a-f74a-4194-8a54-9531205d0883": {
      "main": [
        [
          {
            "node": "78bd1ed8-0c19-4106-ab84-1d25f0f4b806",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a1a606b2-a0d7-4d9c-98b1-4657b902fccd": {
      "main": [
        [
          {
            "node": "0d13634a-f74a-4194-8a54-9531205d0883",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ceaa31cb-bfff-43b6-9433-7d1e124d6d86": {
      "main": [
        [
          {
            "node": "b5512300-5bb4-4781-9d5b-3b61a90d7220",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ef1807a5-8d7c-4d05-b819-a433d495ca36": {
      "main": [
        [
          {
            "node": "d2c8c228-d276-44f7-831b-611d05610e8f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "78bd1ed8-0c19-4106-ab84-1d25f0f4b806": {
      "main": [
        [
          {
            "node": "740fd3e5-f356-436c-ad2b-86da10fb346d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1211ee7a-03d1-4a00-9759-bc0402d3686c": {
      "main": [
        [
          {
            "node": "a1a606b2-a0d7-4d9c-98b1-4657b902fccd",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d655d400-d743-4dd8-8b05-12701c8c4f9d": {
      "main": [
        [
          {
            "node": "5b5250ed-c3de-431f-8e4b-c8b6a6352393",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a6809c8d-ccd9-4acf-9854-b6a36e74c439": {
      "main": [
        [
          {
            "node": "ef1807a5-8d7c-4d05-b819-a433d495ca36",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5b5250ed-c3de-431f-8e4b-c8b6a6352393": {
      "main": [
        [
          {
            "node": "1211ee7a-03d1-4a00-9759-bc0402d3686c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d2c8c228-d276-44f7-831b-611d05610e8f": {
      "main": [
        [
          {
            "node": "1f94c09d-26aa-444b-b607-1366b7ffc4d0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "dc2e73a2-36d8-4d92-947f-b3d01fac934d": {
      "main": [
        [
          {
            "node": "a6809c8d-ccd9-4acf-9854-b6a36e74c439",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b5512300-5bb4-4781-9d5b-3b61a90d7220": {
      "main": [
        [
          {
            "node": "babf93ca-cd95-4a38-9ecc-c16ffbd48dc0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "babf93ca-cd95-4a38-9ecc-c16ffbd48dc0": {
      "main": [
        [
          {
            "node": "dc2e73a2-36d8-4d92-947f-b3d01fac934d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Avancé - DevOps

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Avancé
Nombre de nœuds21
Catégorie1
Types de nœuds10
Description de la difficulté

Adapté aux utilisateurs avancés, avec des workflows complexes contenant 16+ nœuds

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34