Skip to content

Ajout premiere partie #1

Ajout premiere partie

Ajout premiere partie #1

Workflow file for this run

name: Continuous Integration
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
lint:
name: Code Linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
test:
name: Unit & Integration Tests
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Upload test coverage
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage/
security-scan:
name: Security Scan
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run OWASP dependency check
uses: dependency-check/Dependency-Check_Action@main
with:
project: 'DevOps Template'
path: '.'
format: 'HTML'
out: 'reports'
args: >
--failOnCVSS 7
--enableRetired
- name: Upload security report
uses: actions/upload-artifact@v3
with:
name: security-report
path: reports/
build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [test, security-scan]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' }}
tags: |
yourorg/app:latest
yourorg/app:${{ github.sha }}
cache-from: type=registry,ref=yourorg/app:latest
cache-to: type=inline
- name: Scan Docker image
uses: aquasecurity/trivy-action@master
with:
image-ref: 'yourorg/app:${{ github.sha }}'
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'