Build website #3727
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: Build website | |
| on: | |
| push: | |
| branches: [main, test-me/*] | |
| pull_request: | |
| schedule: | |
| - cron: "0 0,12 * * *" | |
| workflow_dispatch: | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| actions: read | |
| concurrency: | |
| group: build-${{ github.head_ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/configure-pages@v5 | |
| id: pages | |
| if: (github.ref == 'refs/heads/main') && (github.repository == 'ClimateTown/knowledge-hub') | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: ">=18" | |
| cache: npm | |
| - name: Install the latest version of uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "latest" | |
| - name: Scrape YouTube data | |
| if: ${{ env.YOUTUBE_API_KEY != '' && github.event_name != 'pull_request' }} | |
| run: | # Only run if the API key is set | |
| uv run scripts/youtube.py --api-key $YOUTUBE_API_KEY | |
| - name: Get previews for resources | |
| run: | | |
| uv run scripts/get_og_previews.py | |
| - name: Convert resources to CSV | |
| run: | | |
| uv run scripts/resource_converter.py -i data/resources.yml -o static/ClimateTown-Knowledge-Hub-resources.csv | |
| - run: npm install | |
| # - run: npm ci | |
| - run: npm run build | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: ./build | |
| deploy: | |
| if: (github.ref == 'refs/heads/main') && (github.repository == 'ClimateTown/knowledge-hub') | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| pages: write # to deploy to Pages | |
| id-token: write # to verify the deployment originates from an appropriate source | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - uses: actions/deploy-pages@v4 | |
| id: deployment |