Switch Decap from dev to prod #375
Workflow file for this run
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: Deploy Gatsby site to Pages | |
on: | |
push: | |
branches: ["main"] | |
merge_group: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
jobs: | |
# ESLint | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
cache: yarn | |
- name: Install dependencies | |
run: yarn install | |
- name: ESLint | |
run: yarn run lint | |
# Prettier | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
cache: yarn | |
- name: Install dependencies | |
run: yarn install | |
- name: Prettier | |
run: yarn run fmt:check | |
# Build job | |
build: | |
runs-on: ubuntu-latest | |
env: | |
PATH_PREFIX: ${{ format('/preview/pr-{0}/', github.event.number) }} | |
STAGING: ${{ github.event_name == 'pull_request' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
cache: yarn | |
- name: Restore cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.cache | |
public | |
key: gatsby-${{ hashFiles('gatsby-config.ts') }}-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
gatsby-${{ hashFiles('gatsby-config.ts') }} | |
gatsby | |
- name: Install dependencies | |
run: yarn install | |
- name: Build with Gatsby | |
env: | |
PREFIX_PATHS: ${{ github.event_name == 'pull_request' }} | |
run: yarn run build | |
- name: Upload built pages | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./public | |
- name: Upload gatsby-types.d.ts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: gatsby-types.d.ts | |
path: ./src/gatsby-types.d.ts | |
# Typecheck | |
check: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
cache: yarn | |
- name: Install dependencies | |
run: yarn install | |
- name: Download gatsby-types.d.ts | |
uses: actions/download-artifact@v4 | |
with: | |
name: gatsby-types.d.ts | |
path: ./src/gatsby-types.d.ts | |
- name: Typescript | |
run: yarn run typecheck | |
# Deployment job | |
deploy: | |
# Allow one concurrent deployment | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
needs: [build, check, lint] | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
# Deploy PR-Preview | |
deploy-preview: | |
environment: | |
name: github-pages-staging | |
url: ${{ steps.deployment.outputs.deployment-url }} | |
if: github.event_name != 'push' | |
runs-on: ubuntu-latest | |
needs: [build, check, lint] | |
steps: | |
# Initialize git repo for pr-preview-action | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: github-pages | |
path: public | |
- name: Exract | |
working-directory: public | |
run: tar -xvf artifact.tar && rm artifact.tar | |
- name: Deploy preview | |
uses: rossjrw/pr-preview-action@v1 | |
id: deployment | |
with: | |
source-dir: public | |
preview-branch: previews | |
deploy-repository: aeroteameindhoven/website-staging | |
custom-url: staging.aeroteameindhoven.nl | |
umbrella-dir: preview | |
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} |