Build website #1646
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: 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 | |
# Allow one concurrent deployment | |
concurrency: | |
group: pages | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/configure-pages@v3 | |
id: pages | |
if: (github.ref == 'refs/heads/main') && (github.repository == 'ClimateTown/knowledge-hub') | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 19 | |
cache: npm | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Scrape YouTube data | |
if: ${{ env.YOUTUBE_API_KEY != '' && github.event_name != 'pull_request' }} | |
run: | # Only run if the API key is set | |
python scripts/youtube.py --api-key $YOUTUBE_API_KEY | |
- name: Get previews for resources | |
run: | | |
python scripts/get_og_previews.py | |
- name: Convert resources to CSV | |
run: | | |
python 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@v1 | |
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@v1 | |
id: deployment |