Automated workflow to synchronize changes from maint branch to master branch in DataLad.
-
Add PAT Secret (one-time setup):
# Create a classic PAT at: https://github.com/settings/tokens # Scopes needed: repo, workflow # Add as repository secret named GH_PAT gh secret set GH_PAT --repo datalad/datalad
-
Deploy Workflows:
# Copy workflows to datalad/datalad cp .github/workflows/sync-maint-to-master.yml /path/to/datalad/datalad/.github/workflows/ cp .github/workflows/cleanup-sync-branch.yml /path/to/datalad/datalad/.github/workflows/ # Commit and push to both branches cd /path/to/datalad/datalad git add .github/workflows/ git commit -m "Add automated maint-to-master sync" git push origin master git checkout maint git merge master --no-edit git push origin maint
-
Enable Auto-Merge (optional):
- Go to Settings → General → Pull Requests
- Enable "Allow auto-merge"
Fast-Forward Mode (90% of cases)
- When: Master hasn't diverged from maint
- Action: Direct push to master (no PR)
- Speed: ~20 seconds
- Example: Post-release, only bug fixes on maint
PR Mode (10% of cases)
- When: Master has diverged (has features not in maint)
- Action: Creates/updates PR for review
- Speed: 5-15 minutes (CI + auto-merge)
- Example: Master has new features + maint has fixes
- On push to
maint: Automatically syncs to master - Daily at 2 AM UTC: Checks for any missed syncs (silent if nothing to do)
- Manual: Via workflow_dispatch
Run the automated test suite:
./test-maint-to-master-workflow.shThis creates a test repository and validates:
- ✅ Fast-forward mode (works with default GITHUB_TOKEN)
- ✅ PR creation mode (requires GH_PAT secret)
- ✅ Conflict detection
- ✅ Auto-merge enablement
Test Repository Setup: The test script needs a PAT to test PR creation. For yarikoptic-test org testing:
# PAT should be in: /home/yoh/proj/datalad/datalad-maint-enh-maint-to-master/secret2
# Or create new one and save to that path.github/workflows/sync-maint-to-master.yml- Main synchronization workflow.github/workflows/cleanup-sync-branch.yml- Cleans up sync branch after PR merge.github/workflows/ci.yml- Example CI workflowtest-maint-to-master-workflow.sh- Automated test scriptdocs/- Additional documentation
- SETUP.md - Detailed deployment instructions
- ARCHITECTURE.md - Design decisions and workflow logic
- TROUBLESHOOTING.md - Common issues and solutions
# View recent workflow runs
gh run list --workflow=sync-maint-to-master.yml --repo datalad/datalad --limit 5
# Check for open sync PRs
gh pr list --head maint-to-master --repo datalad/datalad
# View specific workflow run
gh run view <run-id> --log --repo datalad/dataladState: maint == master (both at v1.2.0)
Action: Push fix to maint
Result: Master automatically fast-forwards to maint
Time: ~20 seconds, no PR needed
State: master has feature, maint has fix
Action: Push fix to maint
Result: PR created "Sync maint → master"
Time: ~5-15 minutes (CI + auto-merge)
State: Same file edited differently in both branches
Action: Push to maint
Result: PR created with conflict notice
Next: Manual resolution on maint-to-master branch
If multiple repositories need this workflow, it can be converted to a reusable workflow:
- Single source of truth for multiple repos
- Centralized maintenance and updates
- Consistent behavior across repositories
Not implemented - Current design uses direct workflow files because:
- Simpler to understand and debug
- More transparent (all logic in one file)
- Easier to customize per repository
- Only one repository (datalad/datalad) needs it currently
To convert to reusable workflow:
-
In this repo - Create
.github/workflows/sync-reusable.yml:name: Reusable Maint-to-Master Sync on: workflow_call: secrets: GH_PAT: required: true description: 'Personal Access Token with repo and workflow scopes' # ... (rest of current sync workflow)
-
In consuming repos - Use it:
name: Sync maint → master on: push: branches: [maint] schedule: - cron: '0 2 * * *' jobs: sync: uses: datalad/maint-to-master/.github/workflows/sync-reusable.yml@main secrets: GH_PAT: ${{ secrets.GH_PAT }}
Decision Point: Implement reusable workflow when:
- 3+ DataLad-related repositories need this pattern
- Centralized updates become more valuable than per-repo customization
- Make changes in this repository
- Test with
./test-maint-to-master-workflow.sh - Copy updated workflow to datalad/datalad:
cp .github/workflows/sync-maint-to-master.yml \ /path/to/datalad/datalad/.github/workflows/
- Commit and push to both maint and master
The workflow is self-healing but monitor for:
- Persistent PR conflicts (indicates divergence issues)
- Failed workflow runs (check permissions or GitHub API issues)
- Unopened PRs when divergence exists (check PAT validity)
- Optimize for the common case: Fast-forward happens 90% of the time
- Fail safe: Conflicts pause automation, require manual review
- Transparent: All actions visible in PRs and workflow logs
- Idempotent: Safe to run multiple times
- Silent when successful: No notifications for routine syncs
- Designed: 2026-01-17
- Implementation: Claude Code (Sonnet 4.5)
- Testing: Validated in yarikoptic-test-dandisets organization
- Target: datalad/datalad repository
Status: ✅ Production Ready Fast-Forward Mode: ✅ Fully Functional PR Mode: ✅ Fully Functional (requires GH_PAT) Last Updated: 2026-01-17