CI #211
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 | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
schedule: | |
- cron: '0 3 * * *' | |
env: | |
CI: false | |
jobs: | |
build-web: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-npm-${{ hashFiles('web/package.json') }}-${{ hashFiles('web/package-lock.json') }} | |
- name: Install dependencies | |
working-directory: ./web | |
# Using npm ci is generally faster than running npm i because it caches dependencies | |
run: | | |
npm ci | |
- name: Build the app | |
working-directory: ./web | |
run: | | |
npm run lint | |
npm run build | |
- name: Run component tests | |
working-directory: ./web | |
run: | | |
npm run test | |
- name: Archive webpage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-web | |
path: | | |
web/dist/ | |
build-data: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- uses: Gr1N/setup-poetry@v9 | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pypoetry/virtualenvs | |
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-${{ hashFiles('pyproject.toml') }} | |
- name: Install Dependencies | |
run: | | |
poetry install | |
- name: Build data | |
working-directory: ./scripts | |
run: | | |
poetry run ./dump.py | |
poetry run jupyter nbconvert --execute analyze_dip.ipynb --to notebook | |
- name: Archive webpage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-data | |
path: | | |
scripts/gesetze.json | |
scripts/tagesordnung.json | |
deploy-web: | |
runs-on: ubuntu-latest | |
needs: | |
- build-web | |
- build-data | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifact | |
pattern: artifact-* | |
merge-multiple: true | |
- run: ls -R artifact | |
- name: Add CNAME | |
run: echo "gesetze.peckto.de" > artifact/CNAME | |
- name: Deploy to Github Pages | |
uses: crazy-max/ghaction-github-pages@v4 | |
with: | |
target_branch: gh-pages | |
build_dir: artifact | |
jekyll: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |