管理与治理
Move work between environments
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
If you have a single Git branch the steps to copy work are:
- Push work from one instance to the Git branch.
- Log in to the other instance to pull the work from Git. You can automate pulls.
Multiple branches
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.
- Push the work to the development branch in Git.
- Merge your development branch into your production branch. Refer to the documentation for your Git provider for guidance on doing this:
- In your production n8n instance, pull the changes. You can automate pulls.
Automatically send changes to n8n
You can automate parts of the process of copying work, using the /source-control/pull API endpoint. Call the API after merging the changes:
curl --request POST \
--location '<YOUR-INSTANCE-URL>/api/v1/source-control/pull' \
--header 'Content-Type: application/json' \
--header 'X-N8N-API-KEY: <YOUR-API-KEY>' \
--data '{"force": true}'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:
name: CI
on:
# Trigger the workflow on push or pull request events for the "production" branch
push:
branches: [ "production" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
run-pull:
runs-on: ubuntu-latest
steps:
- name: PULL
# Use GitHub secrets to protect sensitive information
run: >
curl --location '${{ secrets.INSTANCE_URL }}/version-control/pull' --header
'Content-Type: application/json' --header 'X-N8N-API-KEY: ${{ secrets.INSTANCE_API_KEY }}'官方原文和授权
本页来自 N8N 英文官方网站固定快照,并转换成 xueai 静态页面。内容以 N8N 持续更新的官方页面为准。