Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build data job #6

Merged
merged 2 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,65 @@ jobs:
- 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

deploy-test:
runs-on: ubuntu-latest
needs:
- build-web
- build-data

steps:
- uses: Gr1N/setup-poetry@v9
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
pattern: artifact-*
merge-multiple: true

deploy-web:
runs-on: ubuntu-latest
needs: build-web
needs:
- build-web
- build-data
if: github.ref == 'refs/heads/main'

steps:
- uses: Gr1N/setup-poetry@v9
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
pattern: artifact-*
merge-multiple: true

- name: Deploy to Github Pages
uses: crazy-max/ghaction-github-pages@v4
Expand Down
4 changes: 2 additions & 2 deletions scripts/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def dump(url: str, args: dict[str, str]):
cursor = j['cursor']
data += j['documents']
# rate limit
time.sleep(0.3)
time.sleep(0.3)
time.sleep(0.4)
time.sleep(0.4)
return data


Expand Down
2 changes: 1 addition & 1 deletion web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function App() {
<h1>Überblick zu Gesetzesvorhaben der Deutschen Bundesregierung in der 20. Wahlperiode</h1>
<h3>Disclaimer: Diese Seite befindet sich noch im Aufbau und kann falsche oder unvollständige Informationen beinhalten.</h3>
<p>Quelle: <a href="https://dip.bundestag.de">https://dip.bundestag.de/</a>, <a href="https://search.dip.bundestag.de/api/v1/swagger-ui/#">https://search.dip.bundestag.de/api/v1/swagger-ui/#</a></p>
<p>Stand: 24.03.2024</p>
<p>Stand: {(new Date(__BUILD_DATE__)).toLocaleDateString('de-DE')}</p>
<p>Fork me on GitHub: <a href="https://github.com/peckto/gesetze-im-de-bundestag">https://github.com/peckto/gesetze-im-de-bundestag</a></p>
<Divider />
</div>
Expand Down
3 changes: 3 additions & 0 deletions web/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/// <reference types="vite/client" />

// Global constant replacements https://vitejs.dev/config/shared-options.html#define
declare const __BUILD_DATE__: string;
3 changes: 3 additions & 0 deletions web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export default defineConfig(({ mode }) => {
plugins: [
reactRefresh(),
],
define: {
__BUILD_DATE__: new Date(),
},
test: {
globals: true,
environment: 'jsdom',
Expand Down
Loading