在不同环境间复制工作#
¥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 分支。
¥Push work from one instance to the Git branch. 2. 登录另一个实例以从 Git 拉取工作。你可以 自动拉取。
¥Log in to the other instance to pull the work from Git. You can automate pulls.
多个分支#
¥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:
- 在你的开发实例中进行操作。
¥Do work in your developments instance. 2. 将工作推送到 Git 的开发分支。
¥Push the work to the development branch in Git. 3. 将开发分支合并到生产分支。请参阅你的 Git 提供商的文档,以获取相关指导。
¥Merge your development branch into your production branch. Refer to the documentation for your Git provider for guidance on doing this:
-
¥Git: Basic branching and merging 4. 在你的生产环境 n8n 实例中,拉取更改。你可以 自动拉取。
¥In your production n8n instance, pull the changes. You can automate pulls.
自动将更改发送至 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 | |