Final: Add Articles & App Working #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Pipeline for DevVerse App | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
################################################################################ | |
# 1 Β· Formatting & Lint π§ | |
################################################################################ | |
formatting: | |
name: "π§ Format & Lint" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: npm ci | |
- name: Run Prettier | |
run: npm run format | |
- name: Run ESLint | |
run: npm run lint | |
################################################################################ | |
# 2 Β· Run Tests β | |
################################################################################ | |
tests: | |
name: "β Run Tests" | |
runs-on: ubuntu-latest | |
needs: formatting | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- run: npm ci | |
- run: npm test | |
################################################################################ | |
# 3 Β· Coverage π | |
################################################################################ | |
coverage: | |
name: "π Generate & Upload Coverage" | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: npm ci | |
- name: Run coverage | |
run: npm run coverage | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: coverage | |
################################################################################ | |
# 4 Β· Build & Push Docker Image π³π | |
################################################################################ | |
docker: | |
name: "π³ Build & Push Docker Image" | |
runs-on: ubuntu-latest | |
needs: coverage | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build & push image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/devverse-app:${{ github.sha }} | |
ghcr.io/${{ github.repository_owner }}/devverse-app:latest | |
################################################################################ | |
# 5 Β· Deploy π | |
################################################################################ | |
deploy: | |
name: "π Deploy" | |
runs-on: ubuntu-latest | |
needs: docker | |
steps: | |
- name: Connect to Supabase | |
run: | | |
echo "π Connecting to Supabaseβ¦" | |
sleep 2 | |
echo "β Connected to Supabase" | |
- name: Deploy to Vercel | |
run: | | |
echo "π Deploying to Vercelβ¦" | |
sleep 2 | |
echo "β Deployed to Vercel!" | |
################################################################################ | |
# 6 Β· All Done π | |
################################################################################ | |
complete: | |
name: "π All Done" | |
runs-on: ubuntu-latest | |
needs: deploy | |
steps: | |
- name: Final status | |
run: echo "π CI/CD pipeline finished successfully β all done!" |