|
| 1 | +# Quick Start Guide - Infrastructure and Automation |
| 2 | + |
| 3 | +This guide helps you quickly get started with the new infrastructure and automation features added to the Bleedy project. |
| 4 | + |
| 5 | +## What's New? |
| 6 | + |
| 7 | +This PR adds: |
| 8 | +- 🏗️ **Infrastructure as Code** with Pulumi |
| 9 | +- 🤖 **Automation Scripts** for repository management |
| 10 | +- 🐳 **Docker** containerization |
| 11 | +- ⚙️ **Enhanced GitHub Actions** workflows |
| 12 | +- 📊 **Monitoring** strategy documentation |
| 13 | + |
| 14 | +## Quick Setup |
| 15 | + |
| 16 | +### 1. Application Development (No Changes) |
| 17 | + |
| 18 | +Normal development workflow remains unchanged: |
| 19 | + |
| 20 | +```bash |
| 21 | +npm install |
| 22 | +npm run dev |
| 23 | +``` |
| 24 | + |
| 25 | +### 2. Using Docker (Optional) |
| 26 | + |
| 27 | +#### Development Mode |
| 28 | +```bash |
| 29 | +docker-compose up web |
| 30 | +``` |
| 31 | +Access at: http://localhost:5173 |
| 32 | + |
| 33 | +#### Production Mode |
| 34 | +```bash |
| 35 | +docker-compose build |
| 36 | +docker-compose --profile production up nginx |
| 37 | +``` |
| 38 | +Access at: http://localhost:8080 |
| 39 | + |
| 40 | +### 3. Automation Scripts (For Maintainers) |
| 41 | + |
| 42 | +#### List All Branches |
| 43 | +```bash |
| 44 | +cd automation |
| 45 | +pip install -r requirements.txt |
| 46 | +python scripts/branch_manager.py list |
| 47 | +``` |
| 48 | + |
| 49 | +#### Cleanup Stale Branches (Dry Run) |
| 50 | +```bash |
| 51 | +export GITHUB_TOKEN="your-token" |
| 52 | +export GITHUB_REPOSITORY="danelkay93/bleedy" |
| 53 | +python scripts/branch_manager.py cleanup --older-than 180 --dry-run |
| 54 | +``` |
| 55 | + |
| 56 | +#### Post-Merge Cleanup (Dry Run) |
| 57 | +```bash |
| 58 | +python scripts/post_merge_cleanup.py --pr-number 18 --dry-run |
| 59 | +``` |
| 60 | + |
| 61 | +### 4. Infrastructure Management (Optional) |
| 62 | + |
| 63 | +Only needed if managing infrastructure: |
| 64 | + |
| 65 | +```bash |
| 66 | +# Install Pulumi |
| 67 | +curl -fsSL https://get.pulumi.com | sh |
| 68 | + |
| 69 | +# Setup |
| 70 | +cd infrastructure |
| 71 | +pip install -r requirements.txt |
| 72 | +pulumi login |
| 73 | + |
| 74 | +# Preview changes |
| 75 | +pulumi preview |
| 76 | + |
| 77 | +# Apply changes (requires PULUMI_ACCESS_TOKEN) |
| 78 | +pulumi up |
| 79 | +``` |
| 80 | + |
| 81 | +## GitHub Actions Workflows |
| 82 | + |
| 83 | +### Automatic Workflows |
| 84 | + |
| 85 | +These run automatically: |
| 86 | + |
| 87 | +1. **CI Checks** (`ci.yml`) |
| 88 | + - Runs on every push and PR |
| 89 | + - Checks formatting, linting, types, and builds |
| 90 | + |
| 91 | +2. **Docker Compose** (`docker-compose.yml`) |
| 92 | + - Runs on Dockerfile changes |
| 93 | + - Builds and tests containers |
| 94 | + - Security scans with Trivy |
| 95 | + |
| 96 | +3. **Post-Merge Cleanup** (`post-merge-cleanup.yml`) |
| 97 | + - Runs when consolidation PRs are merged |
| 98 | + - Closes old PRs and deletes branches |
| 99 | + |
| 100 | +4. **Branch Management** (`branch-management.yml`) |
| 101 | + - Runs weekly |
| 102 | + - Reports stale branches |
| 103 | + |
| 104 | +### Manual Workflows |
| 105 | + |
| 106 | +Trigger manually from GitHub Actions tab: |
| 107 | + |
| 108 | +1. **Pulumi** (`pulumi.yml`) |
| 109 | + - Deploy infrastructure changes |
| 110 | + - Requires `PULUMI_ACCESS_TOKEN` secret |
| 111 | + |
| 112 | +2. **Branch Management** (`branch-management.yml`) |
| 113 | + - List, cleanup, or protect branches |
| 114 | + - Always use dry-run first! |
| 115 | + |
| 116 | +## Directory Structure |
| 117 | + |
| 118 | +``` |
| 119 | +bleedy/ |
| 120 | +├── automation/ # 🤖 Automation scripts |
| 121 | +│ ├── scripts/ |
| 122 | +│ │ ├── post_merge_cleanup.py |
| 123 | +│ │ └── branch_manager.py |
| 124 | +│ └── requirements.txt |
| 125 | +│ |
| 126 | +├── infrastructure/ # 🏗️ Pulumi IaC |
| 127 | +│ ├── __main__.py |
| 128 | +│ ├── Pulumi.yaml |
| 129 | +│ └── requirements.txt |
| 130 | +│ |
| 131 | +├── .github/workflows/ # ⚙️ GitHub Actions |
| 132 | +│ ├── ci.yml |
| 133 | +│ ├── pulumi.yml |
| 134 | +│ ├── docker-compose.yml |
| 135 | +│ ├── branch-management.yml |
| 136 | +│ └── post-merge-cleanup.yml |
| 137 | +│ |
| 138 | +├── Dockerfile # 🐳 Container build |
| 139 | +├── docker-compose.yml # 🐳 Service orchestration |
| 140 | +├── nginx.conf # 🌐 Production web server |
| 141 | +│ |
| 142 | +└── Documentation |
| 143 | + ├── INFRASTRUCTURE.md # Complete infrastructure guide |
| 144 | + ├── MONITORING.md # Monitoring strategy |
| 145 | + └── automation/README.md # Automation scripts guide |
| 146 | +``` |
| 147 | + |
| 148 | +## Common Tasks |
| 149 | + |
| 150 | +### For Developers |
| 151 | + |
| 152 | +**Normal development** - Nothing changes: |
| 153 | +```bash |
| 154 | +npm install |
| 155 | +npm run dev |
| 156 | +npm run build |
| 157 | +``` |
| 158 | + |
| 159 | +**Test with Docker** - Optional: |
| 160 | +```bash |
| 161 | +docker-compose up web |
| 162 | +``` |
| 163 | + |
| 164 | +### For Maintainers |
| 165 | + |
| 166 | +**List branches**: |
| 167 | +```bash |
| 168 | +cd automation |
| 169 | +pip install -r requirements.txt |
| 170 | +python scripts/branch_manager.py list |
| 171 | +``` |
| 172 | + |
| 173 | +**Cleanup old branches** (always dry-run first): |
| 174 | +```bash |
| 175 | +export GITHUB_TOKEN="your-token" |
| 176 | +python scripts/branch_manager.py cleanup --older-than 180 --dry-run |
| 177 | +``` |
| 178 | + |
| 179 | +**Protect important branches**: |
| 180 | +```bash |
| 181 | +python scripts/branch_manager.py protect --branch master --dry-run |
| 182 | +``` |
| 183 | + |
| 184 | +### For DevOps |
| 185 | + |
| 186 | +**Deploy infrastructure**: |
| 187 | +```bash |
| 188 | +cd infrastructure |
| 189 | +pulumi preview # Always preview first |
| 190 | +pulumi up # Apply changes |
| 191 | +``` |
| 192 | + |
| 193 | +**Check infrastructure status**: |
| 194 | +```bash |
| 195 | +pulumi stack output |
| 196 | +pulumi stack |
| 197 | +``` |
| 198 | + |
| 199 | +## What Needs Configuration? |
| 200 | + |
| 201 | +### Minimal Setup (Everything Works) |
| 202 | +- Nothing! The PR works out of the box for normal development. |
| 203 | + |
| 204 | +### Optional Features |
| 205 | + |
| 206 | +#### For Pulumi (Infrastructure Management) |
| 207 | +1. Create account at [app.pulumi.com](https://app.pulumi.com) |
| 208 | +2. Get access token |
| 209 | +3. Add `PULUMI_ACCESS_TOKEN` to GitHub secrets |
| 210 | +4. Run `pulumi login` locally |
| 211 | + |
| 212 | +#### For Automation Scripts |
| 213 | +1. Generate GitHub personal access token with `repo` scope |
| 214 | +2. Set environment variables: |
| 215 | + ```bash |
| 216 | + export GITHUB_TOKEN="your-token" |
| 217 | + export GITHUB_REPOSITORY="danelkay93/bleedy" |
| 218 | + ``` |
| 219 | + |
| 220 | +#### For Monitoring (Future) |
| 221 | +See `MONITORING.md` for tool recommendations. |
| 222 | + |
| 223 | +## Testing Your Changes |
| 224 | + |
| 225 | +### Test Build |
| 226 | +```bash |
| 227 | +npm run build |
| 228 | +``` |
| 229 | + |
| 230 | +### Test Python Scripts |
| 231 | +```bash |
| 232 | +python3 -m py_compile automation/scripts/*.py |
| 233 | +``` |
| 234 | + |
| 235 | +### Test Docker |
| 236 | +```bash |
| 237 | +docker-compose build |
| 238 | +docker-compose up web |
| 239 | +``` |
| 240 | + |
| 241 | +### Test Workflows (Locally) |
| 242 | +```bash |
| 243 | +# Install act (https://github.com/nektos/act) |
| 244 | +act -l # List workflows |
| 245 | +act pull_request # Simulate PR event |
| 246 | +``` |
| 247 | + |
| 248 | +## Need Help? |
| 249 | + |
| 250 | +### Documentation |
| 251 | +- **Complete infrastructure guide**: [INFRASTRUCTURE.md](INFRASTRUCTURE.md) |
| 252 | +- **Monitoring strategy**: [MONITORING.md](MONITORING.md) |
| 253 | +- **Automation scripts**: [automation/README.md](automation/README.md) |
| 254 | +- **Pulumi setup**: [infrastructure/README.md](infrastructure/README.md) |
| 255 | + |
| 256 | +### Troubleshooting |
| 257 | +- Check GitHub Actions logs for workflow issues |
| 258 | +- Use `--dry-run` flag for all automation scripts |
| 259 | +- Review Docker logs: `docker-compose logs` |
| 260 | +- Check Pulumi state: `pulumi stack` |
| 261 | + |
| 262 | +### Questions? |
| 263 | +- Open an issue in the repository |
| 264 | +- Review documentation in respective directories |
| 265 | +- Check tool-specific documentation |
| 266 | + |
| 267 | +## What's Next? |
| 268 | + |
| 269 | +After merging this PR: |
| 270 | + |
| 271 | +1. **Optional**: Set up Pulumi for infrastructure management |
| 272 | +2. **Optional**: Configure monitoring (see `MONITORING.md`) |
| 273 | +3. **Recommended**: Review automation scripts locally |
| 274 | +4. **Recommended**: Test Docker setup locally |
| 275 | +5. Continue normal development! |
| 276 | + |
| 277 | +--- |
| 278 | + |
| 279 | +**Remember**: All new features are optional and don't affect normal development workflow! |
0 commit comments