Files
nusquama 01b8e260ed creation
2025-11-14 10:42:07 +01:00

31 KiB

GitHub Workflow Version Control Dashboard with Commit History and Rollbacks

https://n8nworkflows.xyz/workflows/github-workflow-version-control-dashboard-with-commit-history-and-rollbacks-8105

GitHub Workflow Version Control Dashboard with Commit History and Rollbacks

1. Workflow Overview

This workflow, titled "GitHub Workflow Version Control Dashboard with Commit History and Rollbacks", serves as an advanced synchronization and version control dashboard for n8n workflows stored and tracked via GitHub. It enables users or automated processes to:

  • Fetch and display commit histories for workflows maintained in GitHub repositories.
  • Compare local n8n workflows with their GitHub counterparts.
  • Sync workflows by creating, updating, or rolling back versions based on commit data.
  • Manage workflows activation and deactivation.
  • Serve dashboard data through webhooks for live interaction.
  • Automate batch synchronization for all workflows or single workflows on demand.
  • Handle error cases and optimize performance with batch processing and conditional logic.

The workflow is logically divided into several functional blocks addressing input reception, data fetching/syncing, comparison and decision-making, GitHub file operations, workflow lifecycle management, and response generation.

Logical Blocks:

  • 1.1 Input Reception and Triggering
  • 1.2 Data Preparation and Globals Setup
  • 1.3 Fetching Workflows and GitHub Data
  • 1.4 Data Comparison and Aggregation
  • 1.5 Workflow Synchronization and Commit Handling
  • 1.6 Workflow Activation/Deactivation
  • 1.7 Response Handling and Dashboard Display

2. Block-by-Block Analysis

1.1 Input Reception and Triggering

Overview:
This block handles incoming requests and scheduled triggers to initiate synchronization or dashboard operations.

Nodes Involved:

  • Webhook-open-dashboard
  • Webhook-actions
  • Schedule Trigger
  • When Executed by Another Workflow

Node Details:

  • Webhook-open-dashboard

    • Type: Webhook
    • Role: Receives HTTP requests to open and serve the dashboard interface.
    • Configuration: Standard webhook with no special parameters; exposes a webhook endpoint.
    • Input: External HTTP requests.
    • Output: Passes data downstream for dashboard processing.
    • Failure Cases: Webhook not reachable, invalid method calls.
  • Webhook-actions

    • Type: Webhook
    • Role: Receives action commands (e.g., workflow sync commands).
    • Input: HTTP requests with action information.
    • Output: Routes to action query processing.
  • Schedule Trigger

    • Type: Schedule Trigger
    • Role: Periodically triggers batch synchronization of all workflows.
    • Configuration: Default scheduling, typically cron or interval based.
    • Output: Starts the 'n8n-sync-all' batch sync process.
    • Failure Cases: Scheduling misconfiguration, missed triggers.
  • When Executed by Another Workflow

    • Type: Execute Workflow Trigger
    • Role: Allows this workflow to be triggered programmatically by other workflows for sync or dashboard updates.
    • Output: Passes execution context downstream.

1.2 Data Preparation and Globals Setup

Overview:
Initial data setup and global variables configuration to standardize data across the workflow.

Nodes Involved:

  • Globals
  • source-sync
  • source-dashboard
  • source-actions

Node Details:

  • Globals

    • Type: Set
    • Role: Defines global constants or variables used throughout the workflow (e.g., default parameters, API keys references).
    • Configuration: Empty in the snapshot, likely populated with key-value pairs in practice.
    • Output: Feeds data to switches and other logic nodes.
  • source-sync, source-dashboard, source-actions

    • Type: Set
    • Role: Separate global context holders for sync, dashboard, and action data respectively.
    • Output: Connects to the main switch node to route processing.

1.3 Fetching Workflows and GitHub Data

Overview:
Fetches all workflows from n8n and GitHub, retrieves commit histories, workflow files, and other GitHub data for comparison.

Nodes Involved:

  • n8n-all-workflows
  • GH | all-workflows
  • GH | Get file commits
  • GH | Get commit info
  • GH | Get commit content
  • GH | Get file data
  • GH | Get File
  • GH | Check directory exists
  • Aggregate
  • Folder exists?
  • GH | Create initial folder

Node Details:

  • n8n-all-workflows

    • Type: n8n node (internal)
    • Role: Fetches all workflows available in the current n8n instance.
    • Output: Provides local workflows to compare against GitHub.
  • GH | all-workflows

    • Type: GitHub node
    • Role: Fetches all workflow files from the GitHub repository.
    • Output: Provides GitHub workflow data.
  • GH | Get file commits

    • Type: HTTP Request
    • Role: Retrieves commit history for specific workflow files from GitHub.
    • Output: Passes commit data for further processing.
  • GH | Get commit info and GH | Get commit content

    • Type: HTTP Request
    • Role: Fetches detailed commit metadata and content for rollback or sync decisions.
    • Output: Provides commit-level details.
  • GH | Get file data and GH | Get File

    • Type: GitHub and HTTP Request nodes respectively
    • Role: Obtains the latest file data or downloads files if too large.
    • Output: Supplies content for comparison.
  • GH | Check directory exists

    • Type: GitHub node
    • Role: Checks if necessary directories for workflows exist in GitHub.
    • Output: Guides whether folder creation is needed.
  • Aggregate and Folder exists?

    • Type: Aggregate and If nodes
    • Role: Aggregates data and branches logic for folder existence.
  • GH | Create initial folder

    • Type: GitHub node
    • Role: Creates missing directories in GitHub repos for workflow storage.

1.4 Data Comparison and Aggregation

Overview:
Compares the datasets of workflows from n8n and GitHub, determines differences, and aggregates results for decision-making.

Nodes Involved:

  • Edit Fields1, Edit Fields2, Edit Fields3, Edit Fields4, Edit Fields
  • Compare Datasets
  • Filter, Filter1
  • Merge, Merge1, Merge2, Merge3, Merge4, Merge5, Merge6, Merge7
  • Sort
  • Aggregate (b027b064-f332-46bb-a55f-72b1777a6ff4)
  • n8nOnly, synced, githubOnly

Node Details:

  • Edit Fields Nodes

    • Type: Set
    • Role: Prepare and format data fields for comparison or output (e.g., filtering sensitive data, formatting commit metadata).
    • Output: Standardized data for merging and comparison.
  • Compare Datasets

    • Type: Compare Datasets
    • Role: Compares two datasets (e.g., n8n workflows vs GitHub workflows) to find differences, synced items, or exclusive entries.
    • Output: Branches into n8nOnly, synced, githubOnly aggregates.
  • Filter and Filter1

    • Type: Filter
    • Role: Filters data items based on commit details or other criteria for further action.
  • Merge Nodes

    • Type: Merge
    • Role: Combines multiple data streams efficiently, often joining GitHub and n8n data or multiple API responses.
  • Sort

    • Type: Sort
    • Role: Sorts aggregated data, for example by commit date or workflow id.
  • Aggregate, n8nOnly, synced, githubOnly

    • Type: Aggregate
    • Role: Aggregates items by groups or categories to facilitate batch processing or reporting.

1.5 Workflow Synchronization and Commit Handling

Overview:
Manages detailed logic to create, update, or leave workflows unchanged depending on comparison results, including batch processing and commit history management.

Nodes Involved:

  • Query action (switch)
  • fetchCommits
  • Split Commits Path
  • importWorkflow
  • New or Replace? (switch)
  • Create a workflow
  • Update a workflow
  • Sync-single-workflow
  • Sync-all-workflows
  • Loop Over Items
  • Pack Workflow
  • Prepare-sync
  • Filter
  • commit details
  • sticky_note
  • Reduce
  • Final arrays

Node Details:

  • Query action

    • Type: Switch
    • Role: Routes execution based on action type received (e.g., fetch commits, import workflows, prepare sync).
    • Output: Controls main workflow branches.
  • fetchCommits and Split Commits Path

    • Type: Set and Split Out
    • Role: Fetches and splits commit data paths for individual processing.
  • importWorkflow

    • Type: Set
    • Role: Loads workflow data from commit content for import or rollback.
  • New or Replace?

    • Type: Switch
    • Role: Decides whether to create a new workflow or update an existing one based on presence in n8n.
  • Create a workflow, Update a workflow

    • Type: n8n nodes
    • Role: Executes creation or update of workflows in n8n.
  • Sync-single-workflow, Sync-all-workflows

    • Type: Execute Workflow
    • Role: Executes sub-workflows for syncing a single workflow or all workflows in batch.
  • Loop Over Items

    • Type: Split In Batches
    • Role: Processes workflows or commits in manageable batches for efficiency.
  • Pack Workflow, Prepare-sync

    • Type: Set, NoOp
    • Role: Prepares and packages workflow data for syncing.
  • Filter, commit details

    • Type: Filter, Set
    • Role: Filters commits and sets detailed commit info.
  • sticky_note

    • Type: Set
    • Role: Holds notes or comments for debugging or logic comments in the workflow.
  • Reduce, Final arrays

    • Type: Set
    • Role: Consolidates data arrays and prepares responses.

1.6 Workflow Activation/Deactivation

Overview:
Manages the enabling or disabling of workflows in n8n based on sync state or commands.

Nodes Involved:

  • Workflow status (switch)
  • Activate a workflow
  • Deactivate a workflow

Node Details:

  • Workflow status

    • Type: Switch
    • Role: Determines whether to activate or deactivate a workflow based on current command or status.
  • Activate a workflow

    • Type: n8n node
    • Role: Activates a workflow in the n8n instance.
  • Deactivate a workflow

    • Type: n8n node
    • Role: Deactivates a workflow in the n8n instance.
  • Both activation nodes handle errors gracefully with "continueRegularOutput" and respond to webhook after action.


1.7 Response Handling and Dashboard Display

Overview:
Generates HTTP responses to webhook requests, sends data back to clients, and formats dashboard output.

Nodes Involved:

  • Respond to Webhook

  • Respond to Webhook1

  • Respond to Webhook2

  • Respond

  • HTML

  • NOOP, NOOP1, NOOP2 (No Operation placeholders)

Node Details:

  • Respond to Webhook, Respond to Webhook1, Respond to Webhook2, Respond

    • Type: Respond to Webhook
    • Role: Sends HTTP responses to webhook triggers with appropriate payloads (dashboard data, sync results).
    • Input: Data from various processing branches.
    • Output: HTTP response to caller.
  • HTML

    • Type: HTML node
    • Role: Formats and generates HTML content for dashboard display.
    • Output: Feeds formatted data to Respond to Webhook.
  • NOOP nodes

    • Type: NoOp
    • Role: Placeholders to maintain flow structure without processing.

3. Summary Table

Node Name Node Type Functional Role Input Node(s) Output Node(s) Sticky Note
Globals Set Setup global variables source-sync, source-dashboard, source-actions Switch
source-sync Set Global sync context Globals
source-dashboard Set Global dashboard context Globals
source-actions Set Global actions context Globals
Webhook-open-dashboard Webhook Start dashboard interface Merge, source-dashboard
Webhook-actions Webhook Receive action commands Merge1, source-actions
Schedule Trigger Schedule Trigger Periodic batch sync trigger n8n-sync-all
When Executed by Another Workflow Execute Workflow Trigger Triggered by other workflows WorkflowData, source-sync
n8n-all-workflows n8n Node Fetch all local workflows NOOP Edit Fields1
GH all-workflows GitHub Fetch all workflows on GitHub NOOP Edit Fields2
GH Get file commits HTTP Request Fetch commit history for files Split Commits Path Edit Fields4
GH Get commit info HTTP Request Fetch commit metadata Filter commit details
GH Get commit content HTTP Request Fetch commit content Merge5 sticky_note
GH Get file data GitHub Fetch file data If file too large Merge Items
GH Get File HTTP Request Download file if too large Merge Items Merge Items
GH Check directory exists GitHub Check if GitHub directory exists Aggregate Folder exists?
Aggregate Aggregate Aggregate GitHub directory check GH Check directory exists Folder exists?
Folder exists? If Decide folder existence Aggregate GH Create initial folder / Merge7
GH Create initial folder GitHub Create missing GitHub folders Merge7 Merge7
Compare Datasets Compare Datasets Compare n8n vs GitHub workflows Edit Fields1, Edit Fields3, Edit Fields n8nOnly, synced, githubOnly
Edit Fields1 Set Prepare n8n workflows data n8n-all-workflows Compare Datasets
Edit Fields2 Set Prepare GitHub workflows data GH all-workflows Filter1
Edit Fields3 Set Prepare comparison output Edit Fields Compare Datasets
Edit Fields4 Set Format commit data for output GH Get file commits Sort
Edit Fields Set Prepare files for batch processing Filter1 Compare Datasets
Filter Filter Filter commit info GH Get commit info commit details
Filter1 Filter Filter GitHub workflows Edit Fields2 Get all files with the same workflow id
Merge Merge Merge dashboard webhook inputs Webhook-open-dashboard GH Check directory exists / Merge7
Merge1 Merge Merge action webhook inputs Webhook-actions Query action
Merge2 Merge Merge aggregated comparison results n8nOnly, synced, githubOnly Reduce
Merge3 Merge Merge dashboard source and HTML output Get Dashboard Source, HTML Respond to Webhook
Merge4 Merge Merge edited fields for comparison Edit Fields1, Edit Fields3 Compare Datasets
Merge5 Merge Merge commit details and import workflow data importWorkflow, commit details, GH sticky_note
Merge6 Merge Merge workflow data with GitHub file data WorkflowData, Merge Items Switch
Merge7 Merge Merge GitHub folder creation with dashboard source Folder exists?, GH Create initial folder Get Dashboard Source, Merge3
Sort Sort Sort commit data for response Edit Fields4 Respond to Webhook2
Reduce Set Reduce and prepare final arrays for response Merge2 Final arrays
Final arrays Set Final data preparation for response Reduce Respond to Webhook1
Query action Switch Route based on received action type Merge1 Various action branches
fetchCommits Set Prepare commit fetch request Query action Split Commits Path
Split Commits Path Split Out Split commit paths for individual processing fetchCommits GH Get file commits
importWorkflow Set Prepare workflow import data Query action Merge5, GH Get commit content, GH
New or Replace? Switch Decide between creating or updating workflow Code1 Create a workflow, Update a workflow
Create a workflow n8n Node Create new workflow in n8n New or Replace? Respond
Update a workflow n8n Node Update existing workflow in n8n New or Replace? Respond
Sync-single-workflow Execute Workflow Sub-workflow for syncing a single workflow Pack Workflow Respond
Sync-all-workflows Execute Workflow Sub-workflow for syncing all workflows in batch Loop Over Items NOOP1
Loop Over Items Split In Batches Batch processing of workflows or commits n8n-sync-all, NOOP1 NOOP2, Sync-all-workflows
Pack Workflow Set Package workflow data for syncing n8n-fetch-single Sync-single-workflow
Prepare-sync NoOp Preparation placeholder for sync Query action n8n-fetch-single
Workflow status Switch Decide activation or deactivation Query action Activate a workflow, Deactivate a workflow
Activate a workflow n8n Node Activate a workflow in n8n Workflow status Respond
Deactivate a workflow n8n Node Deactivate a workflow in n8n Workflow status Respond
Respond to Webhook Respond to Webhook Send HTTP response to dashboard or sync requests Multiple merges and sets
Respond to Webhook1 Respond to Webhook Send final aggregated sync response Final arrays
Respond to Webhook2 Respond to Webhook Send sorted commit data response Sort
Respond Respond to Webhook Generic response node for workflow creation or update Create a workflow, Update a workflow, Activate, Deactivate
HTML HTML Format dashboard HTML output Merge3 Respond to Webhook
NOOP NoOp Placeholder node Query action n8n-all-workflows, GH all-workflows
NOOP1 NoOp Placeholder for sync batches Sync-all-workflows Loop Over Items
NOOP2 NoOp Placeholder after batch loop Loop Over Items Sync-all-workflows

4. Reproducing the Workflow from Scratch

  1. Create Input Reception Nodes:

    • Add a Webhook node named Webhook-open-dashboard with default settings to accept HTTP GET requests for dashboard access.
    • Add a Webhook node named Webhook-actions to accept POST/PATCH requests for workflow actions.
    • Add a Schedule Trigger node named Schedule Trigger with a desired interval (e.g., every 1 hour) to trigger batch sync.
    • Add an Execute Workflow Trigger node named When Executed by Another Workflow for inter-workflow triggering.
  2. Setup Global Variables:

    • Add three Set nodes named Globals, source-sync, source-dashboard, and source-actions.
    • Configure them to set context variables relevant to their domains (e.g., API keys, repository info).
  3. Fetch Local and GitHub Workflows:

    • Add an n8n node called n8n-all-workflows to fetch all workflows from the current n8n instance.
    • Add a GitHub node named GH | all-workflows with configured GitHub credentials to fetch workflow files from the specified repository.
    • Connect both to nodes that prepare and edit fields (Edit Fields1 and Edit Fields2 respectively) using Set nodes, formatting data uniformly.
  4. Fetch Commit Histories and File Data from GitHub:

    • Add an HTTP Request node named GH | Get file commits to fetch commit history per file.
    • Add HTTP Request nodes GH | Get commit info and GH | Get commit content to retrieve commit metadata and contents.
    • Add GitHub and HTTP Request nodes GH | Get file data and GH | Get File to fetch file content; implement logic to handle large files using an If node (If file too large).
    • Add GitHub node GH | Check directory exists and Aggregate node to verify repository folder structure.
    • Add If node Folder exists? to conditionally create folders.
    • Add GitHub node GH | Create initial folder to create missing folders if needed.
  5. Compare Workflows Between n8n and GitHub:

    • Add Compare Datasets node to compare n8n workflows and GitHub workflows.
    • Add multiple Set nodes (Edit Fields3, Edit Fields4, etc.) to prepare data for comparison and output formatting.
    • Add Filter nodes to refine commit and workflow data based on criteria.
    • Add Merge nodes to combine data streams logically.
    • Add Sort node to order commit data by date or id.
  6. Implement Synchronization Logic:

    • Add a Switch node Query action to route incoming command types (e.g., sync all, fetch commits, import workflow).
    • Add Set nodes like fetchCommits, importWorkflow, and Pack Workflow to prepare data for sync.
    • Add Split Out node Split Commits Path to process commits individually.
    • Add Switch node New or Replace? to decide between workflow creation or update.
    • Add n8n nodes Create a workflow and Update a workflow configured with n8n credentials to manage workflows.
    • Add Execute Workflow nodes Sync-single-workflow and Sync-all-workflows linked to sub-workflows managing single and batch sync respectively.
    • Add Split In Batches node Loop Over Items to process workflows or commits in batches.
    • Add Switch node Check Status and NoOp nodes (Same file - Do nothing, File is different, File is new) to handle file state differences.
    • Add GitHub nodes GH | Edit existing file and GH | Create new file to update or add files in the repo accordingly.
    • Add Set nodes sticky_note, Reduce, and Final arrays to handle notes and prepare final response data.
  7. Manage Workflow Activation and Deactivation:

    • Add a Switch node Workflow status to route between activation and deactivation commands.
    • Add n8n nodes Activate a workflow and Deactivate a workflow configured to enable or disable workflows.
    • Add Respond to Webhook nodes to reply to activation/deactivation commands.
  8. Handle Responses and Dashboard Output:

    • Add HTML node to format dashboard content.
    • Add Respond to Webhook nodes connected to final merges and sorting to respond to dashboard data requests or sync commands.
    • Add NoOp nodes (NOOP, NOOP1, NOOP2) as placeholders to maintain flow structure.
  9. Connect Nodes According to Logic:

    • Connect input nodes to their respective processing branches based on the detailed connections described in the summary.
    • Ensure error handling is configured (e.g., continueRegularOutput on workflow activation/deactivation nodes).
    • Use merges and switches to route data properly.
  10. Credential Setup:

    • Configure GitHub credentials with appropriate scopes for repository content access and commits.
    • Configure n8n credentials for managing workflows and executions.
    • Configure webhook URLs and schedule triggers according to your environment.
  11. Sub-Workflow Setup:

    • Set up sub-workflows for Sync-single-workflow and Sync-all-workflows that handle syncing logic for single and batch workflows respectively.
    • Define inputs as workflow data or commit info.
    • Define outputs as success/failure responses.

5. General Notes & Resources

Note Content Context or Link
This workflow uses advanced GitHub API integrations and requires appropriate GitHub OAuth tokens with repo scope. GitHub API Documentation: https://docs.github.com/en/rest
The workflow is designed for n8n version supporting nodes like Compare Datasets (v2.3) and Execute Workflow Trigger (v1.1). n8n Node Docs: https://docs.n8n.io/nodes/
Use batch processing (Loop Over Items) to avoid rate limits when syncing many workflows or commits. n8n batching best practices
The workflow includes placeholders (NoOp) and sticky notes for logic clarity and debugging purposes. n8n workflow design recommendations
For rollback or commit content fetch, large files are handled by conditional HTTP requests to avoid timeouts. GitHub file size limits and API constraints
Dashboard responses are formatted with HTML nodes to provide a user-friendly interface via webhooks. Webhook usage in n8n: https://docs.n8n.io/integrations/builtin/nodes/n8n-nodes-base.webhook

Disclaimer:
The text and workflow described originate exclusively from an automated workflow created with n8n, an integration and automation tool. This processing strictly respects current content policies and contains no illegal, offensive, or protected elements. All data handled is legal and public.