|
| 1 | +# GitHub Actions for Learning |
| 2 | + |
| 3 | +## What is GitHub Actions? |
| 4 | + |
| 5 | +GitHub Actions is a CI/CD (Continuous Integration/Continuous Deployment) system built into GitHub. Think of it as a robot that automatically runs tasks when you push code. |
| 6 | + |
| 7 | +## Why learn this as a student? |
| 8 | + |
| 9 | +1. **Industry Standard**: Every company uses CI/CD |
| 10 | +2. **Portfolio Value**: Shows you understand professional workflows |
| 11 | +3. **Prevents Bugs**: Catches errors before they reach main branch |
| 12 | +4. **Free Learning**: GitHub gives you free compute time to experiment |
| 13 | + |
| 14 | +## The Three Workflows Explained: |
| 15 | + |
| 16 | +### 1. CI Pipeline (ci.yml) |
| 17 | + |
| 18 | +**Purpose**: Test your code automatically |
| 19 | +**When it runs**: Every time you push code or create a pull request |
| 20 | +**What it does**: |
| 21 | + |
| 22 | +- Installs your dependencies |
| 23 | +- Runs your tests |
| 24 | +- Builds your frontend |
| 25 | +- Tests Docker builds |
| 26 | +- If ANY step fails, it marks the commit as "broken" |
| 27 | + |
| 28 | +### 2. CD Pipeline (cd.yml) |
| 29 | + |
| 30 | +**Purpose**: Deploy your code (COMMENTED OUT FOR LEARNING) |
| 31 | +**Status**: Not needed yet since you're not deploying anywhere |
| 32 | +**What it would do**: Push your app to a server when tests pass |
| 33 | + |
| 34 | +### 3. PR Checks (pr-checks.yml) |
| 35 | + |
| 36 | +**Purpose**: Validate pull requests before merging |
| 37 | +**When it runs**: When you open a pull request |
| 38 | +**What it does**: Same as CI but adds a comment to your PR |
| 39 | + |
| 40 | +## For Learning Phase: |
| 41 | + |
| 42 | +**Keep**: CI Pipeline - This will teach you professional testing habits |
| 43 | +**Comment Out**: CD Pipeline - You don't need deployment yet |
| 44 | +**Keep**: PR Checks - Good for team projects or practice |
| 45 | + |
| 46 | +## How to use this: |
| 47 | + |
| 48 | +1. Push your code to GitHub |
| 49 | +2. Go to your repo -> Actions tab |
| 50 | +3. Watch the workflows run |
| 51 | +4. See green checkmarks (pass) or red X (fail) |
| 52 | +5. Click on failed jobs to see what went wrong |
| 53 | +6. Fix the issues and push again |
| 54 | + |
| 55 | +## Learning Benefits: |
| 56 | + |
| 57 | +- Forces you to write tests |
| 58 | +- Teaches you Docker |
| 59 | +- Shows you industry practices |
| 60 | +- Builds good coding habits |
| 61 | +- Looks professional on your GitHub profile |
| 62 | + |
| 63 | +## Simple Commands: |
| 64 | + |
| 65 | +```bash |
| 66 | +# Test locally first |
| 67 | +cd backend && npm test |
| 68 | + |
| 69 | +# Then push |
| 70 | +git add . |
| 71 | +git commit -m "your changes" |
| 72 | +git push |
| 73 | + |
| 74 | +# GitHub Actions will automatically test your code |
| 75 | +``` |
| 76 | + |
| 77 | +This setup will make you a better developer by forcing good practices. |
0 commit comments