Skip to content

Commit a784b12

Browse files
authored
Merge pull request #9 from SecCodeSmith/feature/update-pipeline
Feature/update pipeline
2 parents 2ab3fec + 9298afe commit a784b12

6 files changed

Lines changed: 792 additions & 1 deletion

File tree

‎.github/workflows/README.md‎

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
# 🚀 CI/CD Pipeline Documentation
2+
3+
This repository includes a comprehensive CI/CD pipeline setup using GitHub Actions for automated testing, building, and deployment.
4+
5+
## 📋 Available Workflows
6+
7+
### 1. **Main CI/CD Pipeline** (`.github/workflows/ci.yml`)
8+
- **Triggers**: Push to `main`, `develop`, PRs to `main`
9+
- **Features**:
10+
- ✅ Automated testing with Vitest
11+
- 🏗️ Build verification
12+
- 🔍 ESLint code quality checks
13+
- 📊 Test coverage reporting
14+
- 💬 Automatic PR comments with test results
15+
- 🏷️ Status badges for repository
16+
17+
### 2. **Release Pipeline** (`.github/workflows/release.yml`)
18+
- **Triggers**: Manual dispatch, Git tags (`v*`)
19+
- **Features**:
20+
- 🔖 Automated version management
21+
- 📝 Changelog generation from git commits
22+
- 📦 Build artifacts (tar.gz, zip)
23+
- 🚀 GitHub Pages deployment
24+
- 📋 Release notes creation
25+
- 🎯 Production-ready builds
26+
27+
### 3. **Pre-release Pipeline** (`.github/workflows/pre-release.yml`)
28+
- **Triggers**: Push to feature branches (`feature/*`, `develop`)
29+
- **Features**:
30+
- 🧪 Development branch testing
31+
- 📅 Timestamp-based versioning
32+
- 🧹 Automatic cleanup of old pre-releases
33+
- 📦 Development artifacts
34+
- 🔄 Continuous integration for development
35+
36+
### 4. **Version Bump** (`.github/workflows/version-bump.yml`)
37+
- **Triggers**: Manual dispatch with version type selection
38+
- **Features**:
39+
- 📈 Semantic version bumping (patch/minor/major)
40+
- 🔀 Pre-release versioning (alpha/beta/rc)
41+
- 📝 Automatic CHANGELOG.md updates
42+
- 🔄 Pull request creation for review
43+
- ✨ Automated commit messages
44+
45+
### 5. **Deployment Status** (`.github/workflows/deployment-status.yml`)
46+
- **Triggers**: Deployment events, workflow completions
47+
- **Features**:
48+
- 📊 Deployment status tracking
49+
- 🎉 Success notifications
50+
- ❌ Failure alerts with troubleshooting
51+
- 🔗 Live URL notifications
52+
53+
## 🎯 Quick Start Guide
54+
55+
### Setting Up the Pipeline
56+
57+
1. **Enable GitHub Actions**:
58+
- Go to repository Settings → Actions → General
59+
- Allow "Read and write permissions" for GITHUB_TOKEN
60+
61+
2. **Configure GitHub Pages**:
62+
- Go to Settings → Pages
63+
- Source: "GitHub Actions"
64+
- This enables automatic deployment
65+
66+
3. **Repository Secrets** (Optional):
67+
- All workflows use the default `GITHUB_TOKEN`
68+
- No additional secrets required for basic setup
69+
70+
### Creating Your First Release
71+
72+
1. **Version Bump**:
73+
```bash
74+
# Option 1: Use GitHub UI
75+
Go to Actions → Version Bump → Run workflow
76+
Select version type (patch/minor/major)
77+
78+
# Option 2: Manual tag
79+
git tag v1.0.0
80+
git push origin v1.0.0
81+
```
82+
83+
2. **Review and Merge**:
84+
- Version bump creates a PR automatically
85+
- Review changes in CHANGELOG.md
86+
- Merge the PR
87+
88+
3. **Create Release**:
89+
- Go to Actions → Release → Run workflow
90+
- Or push a tag to trigger automatically
91+
92+
## 📊 Status Badges
93+
94+
Add these badges to your README.md:
95+
96+
```markdown
97+
![CI](https://github.com/YOUR_USERNAME/YOUR_REPO/actions/workflows/ci.yml/badge.svg)
98+
![Release](https://github.com/YOUR_USERNAME/YOUR_REPO/actions/workflows/release.yml/badge.svg)
99+
![License](https://img.shields.io/github/license/YOUR_USERNAME/YOUR_REPO)
100+
![Version](https://img.shields.io/github/v/release/YOUR_USERNAME/YOUR_REPO)
101+
```
102+
103+
## 🔧 Workflow Details
104+
105+
### Test Pipeline Features
106+
107+
- **Parallel Testing**: Tests run on multiple Node.js versions
108+
- **Coverage Reports**: Automatically generated and commented on PRs
109+
- **Failure Notifications**: Detailed error reporting in PR comments
110+
- **Cache Optimization**: npm dependencies cached for faster builds
111+
112+
### Release Features
113+
114+
- **Semantic Versioning**: Automatic version detection from tags
115+
- **Changelog Generation**: Git commits automatically formatted
116+
- **Multi-format Artifacts**: Both tar.gz and zip distributions
117+
- **GitHub Pages**: Automatic deployment with custom domain support
118+
- **Release Notes**: Formatted release descriptions
119+
120+
### Security Features
121+
122+
- **Minimal Permissions**: Each job has specific permission scopes
123+
- **Token Security**: Uses GitHub's built-in GITHUB_TOKEN
124+
- **Dependency Security**: npm audit checks in CI pipeline
125+
- **Build Verification**: All artifacts verified before deployment
126+
127+
## 🛠️ Customization
128+
129+
### Modifying Test Configuration
130+
131+
Edit `.github/workflows/ci.yml`:
132+
```yaml
133+
# Add more Node.js versions
134+
strategy:
135+
matrix:
136+
node-version: [18.x, 20.x, 22.x]
137+
138+
# Add more test commands
139+
- name: Run additional tests
140+
run: npm run test:e2e
141+
```
142+
143+
### Customizing Release Process
144+
145+
Edit `.github/workflows/release.yml`:
146+
```yaml
147+
# Change deployment target
148+
- name: Deploy to custom server
149+
run: |
150+
# Your custom deployment script
151+
./deploy.sh
152+
```
153+
154+
### Adding Environment Variables
155+
156+
```yaml
157+
env:
158+
NODE_ENV: production
159+
API_URL: ${{ secrets.API_URL }}
160+
```
161+
162+
## 🚨 Troubleshooting
163+
164+
### Common Issues
165+
166+
1. **Tests Failing**:
167+
- Check test logs in Actions tab
168+
- Verify all dependencies are installed
169+
- Ensure test files are properly configured
170+
171+
2. **Deployment Failures**:
172+
- Verify GitHub Pages is enabled
173+
- Check repository permissions
174+
- Ensure build artifacts are generated
175+
176+
3. **Version Bump Issues**:
177+
- Verify package.json exists
178+
- Check Git permissions
179+
- Ensure CHANGELOG.md format is correct
180+
181+
### Debug Mode
182+
183+
Add this to any workflow for verbose logging:
184+
```yaml
185+
env:
186+
ACTIONS_STEP_DEBUG: true
187+
```
188+
189+
## 📈 Monitoring and Analytics
190+
191+
### GitHub Insights
192+
193+
- View workflow runs in Actions tab
194+
- Monitor deployment frequency
195+
- Track test success rates
196+
- Analyze build times
197+
198+
### Performance Optimization
199+
200+
- Use dependency caching
201+
- Parallel job execution
202+
- Minimal artifact sizes
203+
- Efficient Docker layers (if using containers)
204+
205+
## 🤝 Contributing
206+
207+
When contributing to this repository:
208+
209+
1. Create feature branches: `feature/your-feature-name`
210+
2. All PRs trigger automated testing
211+
3. Ensure tests pass before requesting review
212+
4. Follow semantic commit messages for changelog generation
213+
214+
## 📚 Additional Resources
215+
216+
- [GitHub Actions Documentation](https://docs.github.com/en/actions)
217+
- [GitHub Pages Guide](https://docs.github.com/en/pages)
218+
- [Semantic Versioning](https://semver.org/)
219+
- [Conventional Commits](https://www.conventionalcommits.org/)
220+
221+
---
222+
223+
**💡 Tip**: This pipeline is designed to be zero-configuration. Just push your code and let GitHub Actions handle the rest!

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main, develop, feature/github-pipeline ]
5+
branches: [ main, develop, feature/* ]
66
pull_request:
77
branches: [ main, develop ]
88

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Deployment Status
2+
3+
on:
4+
deployment_status:
5+
workflow_run:
6+
workflows: ["Release"]
7+
types: [completed]
8+
9+
jobs:
10+
deployment-notification:
11+
runs-on: ubuntu-latest
12+
if: github.event.deployment_status.state == 'success' || github.event.workflow_run.conclusion == 'success'
13+
14+
steps:
15+
- name: Get deployment info
16+
id: deployment
17+
run: |
18+
if [ "${{ github.event_name }}" = "deployment_status" ]; then
19+
echo "url=${{ github.event.deployment_status.target_url }}" >> $GITHUB_OUTPUT
20+
echo "environment=${{ github.event.deployment_status.environment }}" >> $GITHUB_OUTPUT
21+
echo "state=${{ github.event.deployment_status.state }}" >> $GITHUB_OUTPUT
22+
else
23+
repo_name="${{ github.repository##*/ }}"; echo "url=https://${{ github.repository_owner }}.github.io/${repo_name}" >> $GITHUB_OUTPUT
24+
echo "environment=github-pages" >> $GITHUB_OUTPUT
25+
echo "state=success" >> $GITHUB_OUTPUT
26+
fi
27+
28+
- name: Create deployment summary
29+
run: |
30+
echo "## 🚀 Deployment Successful" >> $GITHUB_STEP_SUMMARY
31+
echo "" >> $GITHUB_STEP_SUMMARY
32+
echo "### Details" >> $GITHUB_STEP_SUMMARY
33+
echo "- **Environment**: ${{ steps.deployment.outputs.environment }}" >> $GITHUB_STEP_SUMMARY
34+
echo "- **Status**: ${{ steps.deployment.outputs.state }}" >> $GITHUB_STEP_SUMMARY
35+
echo "- **URL**: [${{ steps.deployment.outputs.url }}](${{ steps.deployment.outputs.url }})" >> $GITHUB_STEP_SUMMARY
36+
echo "- **Time**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY
37+
echo "" >> $GITHUB_STEP_SUMMARY
38+
echo "### 🎉 Your application is now live!" >> $GITHUB_STEP_SUMMARY
39+
echo "" >> $GITHUB_STEP_SUMMARY
40+
echo "Visit your deployed application: **[${{ steps.deployment.outputs.url }}](${{ steps.deployment.outputs.url }})**" >> $GITHUB_STEP_SUMMARY
41+
42+
deployment-failure:
43+
runs-on: ubuntu-latest
44+
if: github.event.deployment_status.state == 'failure' || github.event.workflow_run.conclusion == 'failure'
45+
46+
steps:
47+
- name: Create failure summary
48+
run: |
49+
echo "## ❌ Deployment Failed" >> $GITHUB_STEP_SUMMARY
50+
echo "" >> $GITHUB_STEP_SUMMARY
51+
echo "### Details" >> $GITHUB_STEP_SUMMARY
52+
echo "- **Environment**: ${{ github.event.deployment_status.environment || 'github-pages' }}" >> $GITHUB_STEP_SUMMARY
53+
echo "- **Status**: ${{ github.event.deployment_status.state || github.event.workflow_run.conclusion }}" >> $GITHUB_STEP_SUMMARY
54+
echo "- **Time**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY
55+
echo "" >> $GITHUB_STEP_SUMMARY
56+
echo "### 🔧 Troubleshooting" >> $GITHUB_STEP_SUMMARY
57+
echo "1. Check the workflow logs for detailed error messages" >> $GITHUB_STEP_SUMMARY
58+
echo "2. Verify that all required secrets and permissions are configured" >> $GITHUB_STEP_SUMMARY
59+
echo "3. Ensure the build artifacts are properly generated" >> $GITHUB_STEP_SUMMARY
60+
echo "4. Check GitHub Pages settings in repository settings" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)