Deploy Static Site #188
This file contains hidden or 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: Deploy Static Site | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Cache Node.js modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: frontend/node_modules | |
| key: node-modules-${{ hashFiles('frontend/package-lock.json') }} | |
| restore-keys: | | |
| node-modules- | |
| - name: Cache Python dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: pip-cache-${{ hashFiles('backend/requirements.txt') }} | |
| restore-keys: | | |
| pip-cache- | |
| - name: Get latest commit hash of content repo | |
| id: content-hash | |
| run: | | |
| HASH=$(curl -s https://api.github.com/repos/research-software-ecosystem/content/commits/master | jq -r .sha) | |
| echo "hash=$HASH" >> $GITHUB_OUTPUT | |
| - name: Restore content from cache | |
| id: cache-content | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| backend/content | |
| key: content-${{ steps.content-hash.outputs.hash }} | |
| - name: Checkout content repository | |
| if: steps.cache-content.outputs.cache-hit != 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: research-software-ecosystem/content | |
| path: backend/content | |
| - name: Install Python dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install -r backend/requirements.txt | |
| - name: Install Node.js dependencies | |
| working-directory: frontend | |
| run: npm install | |
| env: | |
| NUXT_TELEMETRY_DISABLED: 1 | |
| - name: Generate combined metadata JSON file | |
| run: | | |
| python backend/merge_data_files.py | |
| - name: Generate static site | |
| working-directory: frontend | |
| run: npm run generate | |
| env: | |
| NUXT_APP_BASE_URL: /${{ github.event.repository.name }}/ | |
| - name: Deploy | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: frontend/.output/public | |
| force_orphan: true | |
| keep_files: false |