List public probability models #930
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: List public probability models | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
# Run daily at 0:01 UTC | |
schedule: | |
- cron: '1 0 * * *' | |
jobs: | |
list_models: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
kind: | |
- atlas | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install Python dependencies | |
run: | | |
python -m venv venv | |
. venv/bin/activate | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install -r ${{ matrix.kind }}/requirements.txt | |
- name: Generate list of models | |
run: | | |
. venv/bin/activate | |
python ${{ matrix.kind }}/main.py > ${{ matrix.kind }}.json | |
- name: Check valid JSON | |
run: jq -reM '""' ${{ matrix.kind }}.json | |
- name: cat models file to stdout | |
run: cat ${{ matrix.kind }}.json | |
- name: Upload generated list | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.kind }} | |
path: ${{ matrix.kind }}.json | |
prepare_website: | |
runs-on: ubuntu-latest | |
needs: list_models | |
steps: | |
- name: Set up Git repository | |
uses: actions/checkout@v4 | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts/ | |
- name: List artifacts | |
run: ls -R | |
working-directory: artifacts | |
- name: Move to deploy directory | |
run: | | |
find artifacts -name "*.json" -print0 | xargs -0 -I file mv "file" deploy/ | |
- name: Make landing page | |
run: >- | |
find deploy -name "*.json" -type f -exec basename --zero {} \; | |
| xargs -0 -I file printf '<li><a href="file">file</a></li>\n' | |
| xargs -I INSERTED sed -e 's|\$links|INSERTED|' templates/index.html | |
> deploy/index.html | |
- name: List contents | |
run: ls -R | |
working-directory: deploy | |
- name: Check landing page contents | |
run: cat deploy/index.html | |
- name: Fix permissions | |
run: | | |
chmod -c -R +rX "deploy/" | while read line; do | |
echo "::warning title=Invalid file permissions automatically fixed::$line" | |
done | |
- name: Upload artifacts | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: deploy/ | |
deploy: | |
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: prepare_website | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v3 |