πŸ“ Process incoming files and notify via email with GitHub storage

⚑ 4 views Β· πŸ“ File Management

πŸ’‘ Pro Tip β€” If you need GitHub data beyond what the REST API gives you, ScraperNode has a repository scraper that extracts metadata at scale without token rate limits.

View All Scrapers

Description

File Processing Pipeline with Email and GitHub

This workflow automatically ingests newly-uploaded files, validates and transforms their contents, stores the processed files in a GitHub repository, and sends email notifications upon completion. It is ideal for teams that regularly receive data drops and need an auditable, automated pipeline to clean, version, and distribute those files.

Pre-conditions/Requirements

Prerequisites

Required Credentials

CredentialPurposeMinimum Scope
GitHub OAuth2Commit transformed files to a repositoryrepo
SMTP (Email Send)Dispatch success/failure notificationssend

Repository & Email Setup Requirements

ItemExampleNotes
GitHub Repositorygit@github.com:org/data-pipeline.gitBranch must exist (default: main)
Email Recipientsops@company.com, data@company.comComma-separated list

How it works

This workflow automatically ingests newly-uploaded files, validates and transforms their contents, stores the processed files in a GitHub repository, and sends email notifications upon completion. It is ideal for teams that regularly receive data drops and need an auditable, automated pipeline to clean, version, and distribute those files.

Key Steps:

Set up steps

Setup Time: 10-15 minutes

  1. Clone the Workflow: Import the JSON file or copy from the n8n community templates gallery.
  2. Configure Schedule Trigger: Set your desired cron expression (e.g., 0 * * * * for hourly).
  3. HTTP Request Node:
    • Enter the endpoint that lists or returns your new uploads.
    • Add authentication headers if required.
  4. Adjust Validation Code: Open the first Code node and replace the schema rules with your own logic.
  5. Modify Transformation Logic: In the second Code node, apply formatting (e.g., CSV β†’ JSON) or enrichment steps.
  6. GitHub Node:
    • Select your GitHub OAuth2 credential.
    • Specify repository, branch, and file path template (e.g., processed/{{ $json.filename }}).
  7. Email Send Node:
    • Set SMTP credential.
    • Add recipients and customize subject/body with variables.
  8. Test Run: Click β€œExecute Workflow” to ensure end-to-end success.
  9. Activate: Toggle workflow to β€œActive” for autonomous execution.

Node Descriptions

Core Workflow Nodes:

Data Flow:

  1. Schedule Trigger β†’ HTTP Request β†’ SplitInBatches β†’ Code (Validate) β†’ If
    • true β†’ Code (Transform) β†’ Set β†’ GitHub
    • false β†’ Set (Error)
  2. Both branches converge β†’ Email Send

Customization Examples

Custom Validation Rule

// Reject files larger than 5 MB or missing required columns
if (items[0].binary.data.size > 5 * 1024 * 1024) {
  throw new Error('File exceeds 5MB limit');
}
const required = ['id', 'email', 'created_at'];
required.forEach(col => {
  if (!items[0].json.headers.includes(col)) {
    throw new Error(`Missing column: ${col}`);
  }
});
return items;

Dynamic Commit Path Based on Date

const date = new Date().toISOString().split('T')[0]; // YYYY-MM-DD
item.json.gitPath = `archive/${date}/${item.json.filename}`;
return item;

Data Output Format

The workflow outputs structured JSON data:

{
  "filename": "orders_2023-10-01.csv",
  "status": "committed",
  "commitSha": "a1b2c3d4",
  "linesProcessed": 523,
  "errors": []
}

Troubleshooting

Common Issues

  1. GitHub authentication error – Ensure OAuth app is approved and the token has repo scope.
  2. Email not delivered – Verify SMTP host, port, and that β€œless secure apps” are allowed (if using Gmail).

Performance Tips

Pro Tips:


This is a community n8n workflow template provided β€œas-is.” Always review and adapt the workflow to meet your security, compliance, and operational requirements.

πŸ”— Nodes Used

Send Email, GitHub, HTTP Request, Schedule Trigger

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup