在不同环境间复制工作(Copy work between environments)#
将工作从一个 n8n 实例发送到另一个实例的步骤因你使用的是单个 Git 分支还是多个分支而异。
🌐 The steps to send work from one n8n instance to another are different depending on whether you use a single Git branch or multiple branches.
单分支(Single branch)#
如果你只有一个 Git 分支,复制工作的步骤如下:
🌐 If you have a single Git branch the steps to copy work are:
- 将工作从一个实例推送到 Git 分支。
- 登录到另一个实例以从 Git 拉取工作。你可以自动拉取。
多个分支(Multiple branches)#
如果你有多个 Git 分支,你需要在 Git 提供商中合并这些分支,以便在不同环境之间复制工作。在 n8n 中,你无法直接在环境之间复制工作。
🌐 If you have more than one Git branch, you need to merge the branches in your Git provider to copy work between environments. You can't copy work directly between environments in n8n.
常见模式:
🌐 A common pattern is:
- 在你的开发实例中进行操作。
- 将工作推送到 Git 的开发分支。
- 将你的开发分支合并到生产分支。有关操作指南,请查阅你的 Git 提供商的文档:
- 在你的生产 n8n 实例中,拉取更改。你可以自动拉取。
自动将更改发送至 n8n(Automatically send changes to n8n)#
你可以使用 /source-control/pull API 端点自动化部分工作复制过程。在合并更改后调用该 API:
🌐 You can automate parts of the process of copying work, using the /source-control/pull API endpoint. Call the API after merging the changes:
1 2 3 4 5 | |
这意味着你可以使用 GitHub Action 或 GitLab CI/CD 在合并时自动将更改拉取到生产实例。
🌐 This means you can use a GitHub Action or GitLab CI/CD to automatically pull changes to the production instance on merge.
A GitHub Action example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |