Feature Request: Bidirectional Git Integration for Dify Workflows #41459
glatham36
started this conversation in
Suggestion
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.
Feature Request: Bidirectional Git Integration for Dify Workflows
Problem Statement
Dify currently versions workflows (and other app types — chatflow, agent, completion) using its own internal versioning system, stored in its database. This has several limitations:
Goal: Allow Dify workflow definitions (and their associated static files) to be stored in GitHub or GitLab, with a two-way sync — edits made in the Dify builder UI propagate to a git repo, and edits made directly to files in the repo propagate back into Dify — so that Dify workflows can be versioned, reviewed, and promoted using standard git workflows.
Current State (What Dify Provides Today)
This means any git integration has to be built as an external layer on top of the export/import API, rather than as a modification to how Dify persists changes internally.
Proposed Architecture
Overview
A standalone sync service sits between Dify and the git remote (GitHub/GitLab). It does not require forking or patching Dify core. It has two directions of work:
Dify → Git
workflows/<app_id>/<app_name>.yaml), commit with a descriptive message (app name, editor if available, timestamp), and push.Git → Dify
Scope: DSL vs. "all files"
Workflow DSL (YAML) is diffable and git-friendly — this is the primary sync target. Other associated assets (knowledge base documents, uploaded files, plugin bundles) are binary/DB-backed and don't diff meaningfully as text. Recommendation: scope those out of true two-way sync initially; at most, track them as a manifest (filename + hash + storage reference) alongside the DSL so a workflow's git history at least notes what non-DSL assets it depends on, without trying to version their binary content in git itself.
Conflict handling
The hard problem isn't export/import — it's deciding who wins when both sides change:
Where the sync service could live
Implemented as a lightweight standalone service (polling or webhook-driven), independent of Dify's codebase, calling Dify's existing console/export/import APIs and the git provider's REST APIs (GitHub/GitLab). This avoids maintaining a fork of Dify and keeps the integration resilient to Dify version upgrades.
Phased Rollout
Phase 1 — One-way export (Dify → Git), manual trigger
Prove out DSL export, path/naming conventions, and commit formatting. No import path yet; git is a read-only mirror. Low risk, immediately useful as an audit trail.
Phase 2 — Automated one-way export
Move from manual trigger to polling or webhook-driven export on every save. Introduce the mapping store and content-hash gating.
Phase 3 — One-way import (Git → Dify), manual trigger
Allow a human to manually apply a git-side YAML change back into Dify via the sync service, without full automation yet. Validates the import path and surfaces DSL edge cases (schema validation failures, node ID mismatches).
Phase 4 — Full two-way automated sync
Webhook-driven import on push, loop prevention via hash gating, conflict detection and flagging.
Phase 5 — Hardening
Conflict resolution UX, promotion workflows (e.g. dev branch → prod branch triggering import into a different Dify instance/workspace), CI validation (lint/schema-check DSL on PR before merge).
Open Questions
2. Additional context or comments
No response
3. Can you help us with this feature?
All reactions