Skip to content

feat: add GitHub Actions for automated template setup #1

feat: add GitHub Actions for automated template setup

feat: add GitHub Actions for automated template setup #1

Workflow file for this run

name: Initialize from Template
# This workflow automatically runs when someone creates a repository from this template
on:
push:
branches:
- main
- master
workflow_dispatch:
jobs:
check-and-setup:
runs-on: ubuntu-latest
permissions:
contents: write
# Only run if TEMPLATE_CLAUDE.md exists (indicates this is a fresh template copy)
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check if setup needed
id: check
run: |
if [ -f "TEMPLATE_CLAUDE.md" ]; then
echo "setup_needed=true" >> $GITHUB_OUTPUT
echo "This appears to be a fresh template copy - setup needed"
else
echo "setup_needed=false" >> $GITHUB_OUTPUT
echo "Already initialized - skipping setup"
fi
- name: Auto-setup project
if: steps.check.outputs.setup_needed == 'true'
run: |
# Extract repo name from GitHub context
REPO_NAME="${{ github.event.repository.name }}"
echo "Setting up project: $REPO_NAME"
# Rename TEMPLATE_CLAUDE.md to CLAUDE.md
mv TEMPLATE_CLAUDE.md CLAUDE.md
echo "✓ Renamed TEMPLATE_CLAUDE.md to CLAUDE.md"
# Update CLAUDE.md with repo name
sed -i "s/\[Project Name\]/$REPO_NAME/g" CLAUDE.md || true
echo "✓ Updated CLAUDE.md"
# Create fresh TODOS.md
cat > TODOS.md << EOF
# TODOs for $REPO_NAME
## Setup Tasks
- [ ] Review and customize CLAUDE.md with project-specific details
- [ ] Set up project dependencies (uv, npm, go mod, etc.)
- [ ] Configure secrets if needed (see ClaudeUsage/secrets_management.md)
- [ ] Set up pre-commit hooks (optional, see ClaudeUsage/pre_commit_hooks/)
- [ ] Add initial project structure
## Development Tasks
- [ ] Define core features
- [ ] Set up testing framework
- [ ] Implement first feature
## Documentation Tasks
- [ ] Update README.md with project specifics
- [ ] Document API/architecture decisions
- [ ] Add usage examples
EOF
echo "✓ Created TODOS.md"
# Update README if it's still the template README
if grep -q "BaseProject" README.md 2>/dev/null; then
cat > README.md << EOF
# $REPO_NAME
A project created from the [BaseProject template](https://github.com/AutumnsGrove/BaseProject).
## Quick Start
1. **Review \`CLAUDE.md\`** - Your project context and instructions
2. **Check \`TODOS.md\`** - Your task list
3. **Explore \`ClaudeUsage/\`** - Comprehensive workflow guides
## Using with Claude Code
This project is optimized for [Claude Code CLI](https://docs.claude.com/en/docs/claude-code):
\`\`\`bash
claude "implement user authentication"
\`\`\`
## Documentation
- \`ClaudeUsage/README.md\` - Guide index
- \`ClaudeUsage/git_workflow.md\` - Commit standards
- \`ClaudeUsage/secrets_management.md\` - API key handling
- \`ClaudeUsage/testing_strategies.md\` - Test patterns
## Next Steps
See \`TODOS.md\` for your checklist!
EOF
echo "✓ Updated README.md"
fi
# Make pre-commit hooks executable
if [ -d "ClaudeUsage/pre_commit_hooks" ]; then
chmod +x ClaudeUsage/pre_commit_hooks/* 2>/dev/null || true
echo "✓ Made pre-commit hooks executable"
fi
# Remove template-specific files
rm -f setup_new_project.sh NEW_PROJECT_SETUP.md
echo "✓ Removed template setup script"
# Remove this workflow after first run
rm -f .github/workflows/init-template.yml
echo "✓ Removed initialization workflow"
- name: Commit changes
if: steps.check.outputs.setup_needed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore: initialize from BaseProject template
- Renamed TEMPLATE_CLAUDE.md → CLAUDE.md
- Created fresh TODOS.md
- Updated README.md
- Cleaned up template files
Project ready for development! 🚀" || echo "No changes to commit"
git push || echo "Nothing to push"
- name: Create welcome issue
if: steps.check.outputs.setup_needed == 'true'
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🎉 Welcome to your new project!',
body: `## Your project is ready!
This repository has been automatically initialized from the [BaseProject template](https://github.com/AutumnsGrove/BaseProject).
### ✅ What's been set up:
- \`CLAUDE.md\` - Project context file (customized with your repo name)
- \`TODOS.md\` - Your task checklist
- \`README.md\` - Updated with project info
- \`ClaudeUsage/\` - 16 comprehensive workflow guides
### 🚀 Next steps:
1. **Customize \`CLAUDE.md\`** with your project details
2. **Review \`TODOS.md\`** and start checking off tasks
3. **Explore the guides** in \`ClaudeUsage/\` directory
4. **Start coding** with Claude Code: \`claude "your task"\`
### 📚 Recommended reading order:
1. \`ClaudeUsage/project_structure.md\`
2. \`ClaudeUsage/git_workflow.md\`
3. \`ClaudeUsage/secrets_management.md\`
4. \`ClaudeUsage/testing_strategies.md\`
Happy coding! Feel free to close this issue once you've reviewed everything.`
});