Skip to content

Commit a76bd33

Browse files
author
Mona Al Fouani
committed
Add CI/CD GitHub Actions workflow
1 parent ac58bcd commit a76bd33

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI/CD Pipeline
2+
3+
# Trigger CI on pushes to main and pull requests
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
ci:
14+
name: Continuous Integration
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: '20'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run linter
30+
run: npm run lint
31+
32+
- name: Check code formatting
33+
run: npm run format:check
34+
35+
- name: Run tests
36+
run: npm test
37+
38+
- name: Build project
39+
run: npm run build
40+
41+
- name: Generate log file
42+
run: |
43+
echo "Build completed at $(date)" > build.log
44+
45+
- name: Upload build logs
46+
uses: actions/upload-artifact@v3
47+
with:
48+
name: build-logs
49+
path: build.log
50+
51+
- name: Upload demo site
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: demo-site
55+
path: public/
56+
57+
cd:
58+
name: Continuous Deployment
59+
needs: ci
60+
runs-on: ubuntu-latest
61+
if: github.ref == 'refs/heads/main' # Only deploy from main branch
62+
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v3
66+
67+
- name: Set up Node.js
68+
uses: actions/setup-node@v3
69+
with:
70+
node-version: '20'
71+
72+
- name: Install dependencies
73+
run: npm ci
74+
75+
- name: Build project
76+
run: npm run build
77+
78+
- name: Deploy to GitHub Pages
79+
uses: peaceiris/actions-gh-pages@v6
80+
with:
81+
github_token: ${{ secrets.GITHUB_TOKEN }}
82+
publish_dir: ./public

0 commit comments

Comments
 (0)