Build and Deploy Gatsby site to Pages #2257
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
# Sample workflow for building and deploying a Gatsby site to GitHub Pages | |
# | |
# To get started with Gatsby see: https://www.gatsbyjs.com/docs/quick-start/ | |
# | |
name: Build and Deploy Gatsby site to Pages | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ["main"] | |
schedule: # Run every 4 hours | |
- cron: '0 */4 * * *' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
# Default to bash | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
# Build job | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install minimal stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
- name: Install cargo-html-query from crates.io | |
uses: baptiste0928/cargo-install@v2 | |
with: | |
crate: html-query | |
- name: Install cargo-xq from crates.io | |
uses: baptiste0928/cargo-install@v2 | |
with: | |
crate: xq | |
- name: Get the group data | |
working-directory: ./data-generator/groups | |
run: | | |
export DATA_ENV=production | |
bash ./fetch_and_store.sh | |
ls -al ../data | |
- name: Install ics | |
run: | | |
pip3 install ics | |
- name: Combine the data | |
working-directory: ./data-generator | |
run: | | |
python3 combineOrganizations.py | |
- name: Generage ics file | |
working-directory: ./data-generator | |
run: | | |
python3 generateIcs.py | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
# cache: ${{ steps.detect-package-manager.outputs.manager }} | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v3 | |
with: | |
# Automatically inject pathPrefix in your Gatsby configuration file. | |
# | |
# You may remove this line if you want to manage the configuration yourself. | |
static_site_generator: gatsby | |
- name: Restore cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
public | |
.cache | |
key: ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }} | |
restore-keys: | | |
${{ runner.os }}-gatsby-build- | |
- name: Install dependencies | |
working-directory: ./web | |
run: yarn | |
- name: Build with Gatsby | |
working-directory: ./web | |
env: | |
PREFIX_PATHS: 'false' | |
run: yarn build | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./web/public | |
# Deploy job | |
deploy: | |
# Add a dependency to the build job | |
needs: build | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# Specify runner + deployment step | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4.0.2 # or the latest "vX.X.X" version tag for this action |