Refactor utils-isValidUsername in backend - Fixes #35 #20
This file contains 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 Pipeline | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
backend-job: | |
name: ExpressJS Backend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js v19 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 19.x | |
cache: "npm" | |
cache-dependency-path: 'backend/package-lock.json' | |
- name: Install Dependencies | |
run: npm ci --legacy-peer-deps | |
working-directory: ./backend | |
- name: Prisma Generate | |
run: npx prisma generate | |
working-directory: ./backend | |
- name: Build | |
run: npm run build | |
working-directory: ./backend | |
- name: Lint | |
run: npm run lint | |
working-directory: ./backend | |
- name: Run Tests | |
run: npm test | |
working-directory: ./backend | |
frontend-job: | |
name: ReactJS Frontend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js v19 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 19.x | |
cache: "npm" | |
cache-dependency-path: 'frontend/package-lock.json' | |
- name: Install Dependencies | |
run: npm ci | |
working-directory: ./frontend | |
- name: Build | |
run: npm run build | |
working-directory: ./frontend | |
- name: Lint | |
run: npm run lint | |
working-directory: ./frontend | |
- name: Run Tests | |
run: npm test | |
working-directory: ./frontend | |
sonarcube-analysis: | |
name: Static Code Analysis | |
runs-on: ubuntu-latest | |
needs: [frontend-job, backend-job] | |
permissions: read-all | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- uses: sonarsource/sonarqube-scan-action@master | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
# If you wish to fail your job when the Quality Gate is red, uncomment the | |
# following lines. This would typically be used to fail a deployment. | |
- uses: sonarsource/sonarqube-quality-gate-action@master | |
timeout-minutes: 5 | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
deploy-job: | |
name: Deploy to Server | |
needs: [ backend-job, frontend-job] | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Configure SSH | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
HOST: ${{ secrets.SSH_HOST }} | |
USERNAME: ${{ secrets.SSH_USERNAME }} | |
PORT: ${{ secrets.SSH_PORT }} | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan -p $SSH_PORT $SSH_HOST >> ~/.ssh/known_hosts | |
ssh -p $PORT $SSH_USERNAME@$SSH_HOST '~/deploy_script.sh' | |
lighthouse-job: | |
name: Lighthouse Audit | |
runs-on: ubuntu-latest | |
needs: [deploy-job] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Audit URLs using Lighthouse | |
uses: treosh/lighthouse-ci-action@v10 | |
with: | |
urls: | | |
${{ secrets.APP_URL }} | |
budgetPath: ./budget.json # test performance budgets | |
uploadArtifacts: true # save results as an action artifacts | |
temporaryPublicStorage: true # upload lighthouse report to the temporary storage |