Skip to content

Update ci-cd.dev.yml #32

Update ci-cd.dev.yml

Update ci-cd.dev.yml #32

Workflow file for this run

name: CI/CD Dev Pipeline
on:
push:
branches:
- develop
pull_request:
branches:
- develop
env:
ENVIRONMENT: dev
DATABASE_URL: ${{ secrets.DATABASE_URL }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
NEXT_PUBLIC_SITE_URL: ${{ secrets.NEXT_PUBLIC_SITE_URL }}
NEXT_PUBLIC_SOCKET_URL: ${{ secrets.NEXT_PUBLIC_SOCKET_URL }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
jobs:
deps-vulnerability:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Create lock file
run: |
cd ./satsquare
npm install --package-lock-only
- name: Install dependencies
run: |
cd ./satsquare
npm ci
npm update
- name: Install jest-environment-jsdom
run: |
cd ./satsquare
npm install jest-environment-jsdom --save-dev
- name: Audit npm dependencies
run: |
cd ./satsquare
npm audit --audit-level=moderate
lint:
needs: deps-vulnerability
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm ci
- name: Run Linting
run: |
cd ./satsquare
npm run lint
unit-tests:
# needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm ci
npm i jest-environment-jsdom jest
- name: Run Jest Unit Tests
run: |
cd ./satsquare
npm run test
codecov:
# needs: unit-tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm ci
npm i jest-environment-jsdom jest
- name: Run tests and generate coverage report
run: |
cd ./satsquare
npm run test -- --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
# security:
# # needs: codecov
# runs-on: ubuntu-latest
# permissions:
# pull-requests: write
# security-events: write
# statuses: write
# contents: write
# issues: write
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - uses: mobb-dev/[email protected]
# with:
# mobb-api-token: ${{ secrets.MOBB_API_TOKEN }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
lighthouse:
# needs: security
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm install
- name: Run Lighthouse CI
run: |
cd ./satsquare
npx lhci autorun
# docker-build:
# # needs: lighthouse
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Login to GitHub Container Registry
# run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# - name: Build Docker image
# run: |
# cd ./satsquare
# docker run -e DATABASE_URL="${{ secrets.DATABASE_URL }}" \
# -e NEXTAUTH_SECRET="${{ secrets.NEXTAUTH_SECRET }}" \
# -e NEXT_PUBLIC_SITE_URL="${{ secrets.NEXT_PUBLIC_SITE_URL }}" \
# -e NEXT_PUBLIC_SOCKET_URL="${{ secrets.NEXT_PUBLIC_SOCKET_URL }}" \
# -p 3000:3000 -p 5157:5157
# docker build -t ghcr.io/ismail-mouyahada/sat-square:dev-${{ github.sha }} -f Dockerfile.dev .
# - name: Scan Docker image for vulnerabilities
# uses: aquasecurity/[email protected]
# with:
# image-ref: ghcr.io/ismail-mouyahada/sat-square:dev-${{ github.sha }}
# - name: Push Docker image to GitHub Container Registry
# run: docker push ghcr.io/ismail-mouyahada/sat-square:dev-${{ github.sha }}
e2e-tests:
# needs: docker-build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm install
- name: Run end-to-end tests
run: |
cd ./satsquare
npm run test:e2e
stress-test:
needs: e2e-tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
cd ./satsquare
npm install
- name: Run stress tests
run: |
cd ./satsquare
npm run test:stress
notify:
runs-on: ubuntu-latest
# needs: [stress-test]
steps:
- name: Notify Discord
uses: discord-actions/message@v2
with:
webhookUrl: "https://discord.com/api/webhooks/1278096229351293008/UdVm3whQn9wb_neR4tuS5TGFfFzaiAo4Jijwa0yuEks1GwoVdrV-lcsdvw5qlA0Kq9CN"
message: "On est la les BG"
username: "Github"
avatar: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
- name: Notify Discord
if: success()
uses: discord-actions/message@v2
with:
webhookUrl: "https://discord.com/api/webhooks/1278096229351293008/UdVm3whQn9wb_neR4tuS5TGFfFzaiAo4Jijwa0yuEks1GwoVdrV-lcsdvw5qlA0Kq9CN"
message: "Bah Oui ça marche mon gasr 🗺 "
- name: Notify Discord
if: failure()
uses: discord-actions/message@v2
with:
webhookUrl: "https://discord.com/api/webhooks/1278096229351293008/UdVm3whQn9wb_neR4tuS5TGFfFzaiAo4Jijwa0yuEks1GwoVdrV-lcsdvw5qlA0Kq9CN"
message: "Ops tu as glissé mon pote ☣ "
- name: Notify Discord
if: ${{ always() && contains(needs.*.result, 'failure') }}
uses: discord-actions/message@v2
with:
webhookUrl: "https://discord.com/api/webhooks/1278096229351293008/UdVm3whQn9wb_neR4tuS5TGFfFzaiAo4Jijwa0yuEks1GwoVdrV-lcsdvw5qlA0Kq9CN"
message: "C'était presque bon mon kiki ! 😇 "