A reusable GitHub workflow that organizes timestamped markdown files from an inbox repository into structured /journal directories. Supports a 3-repository architecture: sofadb/inbox (this repo), user/inbox (markdown files), and user/journal (organized files).
Recommended: Fork this repository to get automatic updates and use the pre-built Docker image.
- Fork this repository
- The Docker image is automatically built and published to GHCR
- Configure secrets (see step 2 below)
Create a workflow in your journal repository that calls this reusable workflow:
# .github/workflows/organize-journal.yml in your journal repo
name: Organize Journal Files
on:
schedule:
- cron: '0 2 * * *' # Daily at 2 AM UTC
workflow_dispatch:
permissions:
contents: write
jobs:
organize:
uses: sofadb/inbox-organizer/.github/workflows/organize.yml@main
with:
inbox_repo: 'username/inbox' # Your inbox repository
inbox_path: '/inbox' # Path to inbox files (/ or /inbox)
image_tag: 'latest'
secrets:
inbox_token: ${{ secrets.INBOX_ACCESS_TOKEN }}This workflow will:
- Clone your inbox repository
- Copy .md files from the inbox to your journal
- Organize them into date-based directories
- Clean the processed files from your inbox repository
- Commit the organized files to your journal repository
For Option B (Reusable workflow):
Create these secrets in your journal repository:
- Go to Settings → Secrets and variables → Actions
- Add secrets:
INBOX_ACCESS_TOKEN: Personal Access Token withreposcope to access and modify your inbox repository
Repository Permissions:
Ensure your journal repo has Actions enabled with write permissions:
- Settings → Actions → General → Workflow permissions
- Select Read and write permissions
- Go to the Actions tab in your repository
- If Actions are disabled, click "I understand my workflows, go ahead and enable them"
This project uses a 3-repository architecture:
sofadb/inbox(this repo): Contains the reusable workflow and Docker imageuser/inbox: Contains your markdown files (configurable path:/or/inbox)user/journal: Contains your organized journal files in date-based directories
- Builds and publishes Docker image to GHCR
- Triggers on changes to
Dockerfileororganize_files.py - Multi-platform builds (AMD64/ARM64)
- Semantic versioning support
- Clones your inbox repository
- Copies .md files to the journal repository
- Organizes files into date-based directories
- Cleans processed files from the inbox repository
- Commits organized files to the journal repository
- Input: Files in your inbox repository (configurable path:
/or/inbox) with patternYYYYMMDDHHMMSS.md - Output: Files organized in your journal repository to
/journal/YYYY/MM/DD/YYYYMMDDHHMMSS.md
Example Flow:
1. Inbox Repository (user/inbox):
/inbox/20241225143000.md
2. Journal Repository (user/journal):
/journal/2024/12/25/20241225143000.md
3. Inbox Repository (after processing):
/inbox/ (file removed)
The workflow runs automatically daily at 2:00 AM UTC.
Edit .github/workflows/organize-journal.yml and modify the cron schedule:
on:
schedule:
- cron: '0 2 * * *' # Daily at 2 AM UTC# Every 6 hours
- cron: '0 */6 * * *'
# Twice daily (6 AM and 6 PM UTC)
- cron: '0 6,18 * * *'
# Every Monday at 9 AM UTC
- cron: '0 9 * * 1'
# Every hour
- cron: '0 * * * *'
# Every 30 minutes
- cron: '*/30 * * * *'┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday)
│ │ │ │ │
* * * * *
You can also run the workflow manually:
- Go to Actions tab in your repository
- Click on "Organize Journal Files" workflow
- Click "Run workflow" button
- Click "Run workflow" in the dropdown
To test the Docker container locally with your private repo:
# Clone your private repo locally
git clone https://github.com/username/your-private-repo.git test-repo
# Build the image
docker build -t file-organizer .
# Add test files to inbox
echo "# Test content" > test-repo/inbox/20241225143000.md
# Run the organizer
docker run --rm -v $(pwd)/test-repo:/data file-organizer
# Check results
ls test-repo/journal/2024/12/25/- Check that Actions are enabled in repository settings
- Verify the workflow file is in
.github/workflows/directory - Check the Actions tab for any error messages
- Verify the Personal Access Token has
reposcope - Check that
PRIVATE_REPOandPRIVATE_REPO_TOKENsecrets are correctly set - Ensure the token hasn't expired
- Verify files follow the exact pattern:
YYYYMMDDHHMMSS.md - Check the Actions logs for detailed error messages
- Ensure files are in the
/inboxdirectory
To view workflow execution details:
- Go to Actions tab
- Click on a workflow run
- Click on the "organize-files" job to see detailed logs
The current algorithm can be enhanced by modifying organize_files.py:
- Add file content analysis
- Support different file types
- Add duplicate detection
- Implement custom naming schemes
- Add metadata extraction