Skip to content

ci: bump workflows #102

ci: bump workflows

ci: bump workflows #102

Workflow file for this run

name: Smoketest
on:
push:
pull_request:
workflow_dispatch:
env:
NODE_VERSION: 20.x
jobs:
install:
runs-on: ubuntu-latest
name: Prepare repo
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Cache node_modules for other runs
uses: actions/cache@v3
id: module-cache
with:
path: ./node_modules
key: ${{ runner.os }}-node-modules-${{ github.sha }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-${{ github.sha }}-
${{ runner.os }}-node-modules-
- name: Install dependencies on cache miss
run: yarn install --frozen-lockfile
if: steps.yarn-cache.outputs.cache-hit != 'true'
- name: Install project dependencies from cache
run: yarn --prefer-offline --frozen-lockfile
if: steps.yarn-cache.outputs.cache-hit == 'true'
formatting:
runs-on: ubuntu-latest
needs: [install]
name: Verify formatting
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Restore dependencies cache
uses: actions/cache@v3
id: module-cache
with:
path: ./node_modules
key: ${{ runner.os }}-node-modules-${{ github.sha }}-${{ hashFiles('yarn.lock') }}
- name: Verify formatting
run: yarn format:check
# test:
# runs-on: ubuntu-latest
# needs: [install]
# name: Run tests
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Use Node.js ${{ env.NODE_VERSION }}
# uses: actions/setup-node@v2
# with:
# node-version: ${{ env.NODE_VERSION }}
# - name: Restore dependencies cache
# uses: actions/cache@v2
# id: moduleCache
# with:
# path: ./node_modules
# key: ${{ runner.os }}-node-modules-${{ github.sha }}-${{ hashFiles('yarn.lock') }}
# - name: Run tests
# run: yarn test
# - name: Upload coverage
# # Run even if tests fail
# if: always()
# uses: codecov/codecov-action@v1
# with:
# directory: coverage
build:
name: Build site
runs-on: ubuntu-latest
needs: [formatting]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Restore dependencies cache
uses: actions/cache@v3
id: module-cache
with:
path: ./node_modules
key: ${{ runner.os }}-node-modules-${{ github.sha }}-${{ hashFiles('yarn.lock') }}
- name: Restore Gatsby cache
uses: actions/cache@v3
id: gatsbyCache
with:
path: ./.cache
key: ${{ runner.os }}-gatsby-cache-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-gatsby-cache-
- name: Restore Gatsby build output
uses: actions/cache@v3
id: gatsbyOut
with:
path: ./public
key: ${{ runner.os }}-gatsby-out-${{ hashFiles('yarn.lock') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-gatsby-out-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-gatsby-out-
- name: Build site
run: yarn build:ci
deploy:
name: Deploy site to production
runs-on: ubuntu-latest
needs: [build, formatting, install]
# Only deploy on push to deploy branch
if: github.ref == 'refs/heads/deploy' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Restore Gatsby cache
uses: actions/cache@v3
id: gatsbyCache
with:
path: ./.cache
key: ${{ runner.os }}-gatsby-cache-${{ hashFiles('yarn.lock') }}
- name: Restore Gatsby output
uses: actions/cache@v3
id: gatsbyOut
with:
path: ./public
key: ${{ runner.os }}-gatsby-out-${{ hashFiles('yarn.lock') }}-${{ github.sha }}
- name: Upload a compiled website
uses: actions/upload-artifact@v3
with:
name: Compiled website
path: public/
- name: Deploy to GitHub Pages 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: prod
folder: public
clean: true