diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 0000000..05df1ed --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,78 @@ +name: CI/CD Pipeline + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + ci: + name: Continuous Integration + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install dependencies + run: npm ci + + - name: Run linter + run: npm run lint + + - name: Check formatting + run: npm run format:check + + - name: Run tests + run: npm test + + - name: Build project + run: npm run build + + - name: Generate log file + run: echo "Build completed at $(date)" > build.log + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: build-logs + path: build.log + + - name: Upload demo site + uses: actions/upload-artifact@v4 + with: + name: demo-site + path: public/ + + cd: + name: Continuous Deployment + runs-on: ubuntu-latest + needs: ci # This job depends on the CI job + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install dependencies + run: npm ci + + - name: Build project + run: npm run build + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./public \ No newline at end of file