Skip to content

Add CI/CD GitHub Actions workflow #1

Add CI/CD GitHub Actions workflow

Add CI/CD GitHub Actions workflow #1

Workflow file for this run

name: CI/CD Pipeline
# Trigger CI on pushes to main and pull requests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
ci:
name: Continuous Integration
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Check code 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 build logs
uses: actions/upload-artifact@v3
with:
name: build-logs
path: build.log
- name: Upload demo site
uses: actions/upload-artifact@v3
with:
name: demo-site
path: public/
cd:
name: Continuous Deployment
needs: ci
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' # Only deploy from main branch
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
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@v6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public