|
| 1 | +name: PowerPulse CI/CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop, 'release/**' ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, develop ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v3 |
| 14 | + - name: Set up Node.js |
| 15 | + uses: actions/setup-node@v3 |
| 16 | + with: |
| 17 | + node-version: '18' |
| 18 | + cache: 'npm' |
| 19 | + - name: Install dependencies |
| 20 | + run: npm run install-all |
| 21 | + - name: Lint client code |
| 22 | + run: cd client && npm run lint |
| 23 | + - name: Lint server code |
| 24 | + run: cd server && npm run lint |
| 25 | + |
| 26 | + test: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + needs: lint |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v3 |
| 31 | + - name: Set up Node.js |
| 32 | + uses: actions/setup-node@v3 |
| 33 | + with: |
| 34 | + node-version: '18' |
| 35 | + cache: 'npm' |
| 36 | + - name: Install dependencies |
| 37 | + run: npm run install-all |
| 38 | + - name: Run client tests |
| 39 | + run: cd client && npm test |
| 40 | + - name: Run server tests |
| 41 | + run: cd server && npm test |
| 42 | + |
| 43 | + build: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + needs: test |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v3 |
| 48 | + - name: Set up Node.js |
| 49 | + uses: actions/setup-node@v3 |
| 50 | + with: |
| 51 | + node-version: '18' |
| 52 | + cache: 'npm' |
| 53 | + - name: Install dependencies |
| 54 | + run: npm run install-all |
| 55 | + - name: Build client |
| 56 | + run: cd client && npm run build |
| 57 | + - name: Upload build artifacts |
| 58 | + uses: actions/upload-artifact@v3 |
| 59 | + with: |
| 60 | + name: build-files |
| 61 | + path: client/dist |
| 62 | + |
| 63 | + # Optional: Add deployment job for production releases |
| 64 | + deploy: |
| 65 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 66 | + runs-on: ubuntu-latest |
| 67 | + needs: build |
| 68 | + steps: |
| 69 | + - name: Download build artifacts |
| 70 | + uses: actions/download-artifact@v3 |
| 71 | + with: |
| 72 | + name: build-files |
| 73 | + path: client/dist |
| 74 | + # Add deployment steps here (e.g., to GitHub Pages, Docker Hub, or your hosting provider) |
0 commit comments