Update README.md #5
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 | |
on: | |
push: | |
branches: [ main, develop ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Run type check | |
run: npm run type-check | |
- name: Run linter | |
run: npm run lint | |
- name: Build project | |
run: npm run build | |
security: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Run security audit | |
run: npm audit --audit-level high | |
- name: Run Snyk to check for vulnerabilities | |
uses: snyk/actions/node@master | |
continue-on-error: true | |
env: | |
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
docker: | |
runs-on: ubuntu-latest | |
needs: [test, security] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image | |
run: docker build -t viaimcode-ai:test . | |
- name: Test Docker image | |
run: | | |
docker run --rm -d --name test-container -p 3000:3000 viaimcode-ai:test | |
sleep 30 | |
curl -f http://localhost:3000/api/health || exit 1 | |
docker stop test-container | |
release: | |
runs-on: ubuntu-latest | |
needs: [test, security, docker] | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Install dependencies | |
run: npm ci | |
- name: Build project | |
run: npm run build | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ github.run_number }} | |
release_name: Release v${{ github.run_number }} | |
body: | | |
## Changes in this Release | |
- Automated release from main branch | |
- Build number: ${{ github.run_number }} | |
- Commit: ${{ github.sha }} | |
draft: false | |
prerelease: false |