summaryrefslogtreecommitdiff
path: root/.github/workflows/cicd.yml
blob: 217d8cdddc449f01abf2ccac5f24e83f62fdff06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Deploy to GitHub Pages

on:
  push:
    branches: [ deploy ]
  pull_request:
    branches: [ deploy ]

concurrency:
  group: "pages"
  cancel-in-progress: true

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  python-tests:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.13'

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
        pip install mypy

    - name: Run unit tests
      run: python -m unittest tests/*.py

    - name: Run type checking
      run: mypy --explicit-package-bases --strict .

  build:
    runs-on: ubuntu-latest
    needs: python-tests

    steps:
    - name: Checkout
      uses: actions/checkout@v4

    - name: Setup Node.js
      uses: actions/setup-node@v4
      with:
        node-version: '18'
        cache: 'npm'
        cache-dependency-path: 'front-end/package-lock.json'

    - name: Create env file
      run: |
        echo "VITE_API_BASE_URL=https://flask.csca5028.farzat.xyz/" > front-end/.env
      working-directory: ./

    - name: Install dependencies
      run: npm ci
      working-directory: ./front-end

    - name: Build
      run: npm run build
      working-directory: ./front-end

    - name: Setup Pages
      uses: actions/configure-pages@v4

    - name: Upload artifact
      uses: actions/upload-pages-artifact@v3
      with:
        path: ./front-end/dist

  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build

    permissions:
      pages: write
      id-token: write

    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4