Skip to content

Merge pull request #145 from DawChihLiou/dependabot/npm_and_yarn/adob… #375

Merge pull request #145 from DawChihLiou/dependabot/npm_and_yarn/adob…

Merge pull request #145 from DawChihLiou/dependabot/npm_and_yarn/adob… #375

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
GIT_USER_EMAIL: ${{secrets.GIT_USER_EMAIL}}
GIT_USER_NAME: ${{secrets.GIT_USER_NAME}}
jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- uses: actions/cache@v3
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Lint source code
run: yarn lint
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- uses: actions/cache@v3
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Unit test
run: yarn test:ci
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- uses: actions/cache@v3
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Run prepare scripts
run: yarn prepare
- uses: actions/cache@v3
id: nextjs-cache
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Build project
if: steps.nextjs-cache.outputs.cache-hit != 'true'
run: yarn build
deploy:
runs-on: ubuntu-20.04
needs: ['lint', 'test', 'build']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- uses: actions/cache@v3
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Remove node modules cache
run: rm -rf node_modules/.cache
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Run prepare scripts
run: yarn prepare
- name: Generate content layer
run: npx contentlayer build
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install binaryen
run: sudo apt-get -y install binaryen
- name: Install twiggy
run: cargo install twiggy
- name: Build full-text search WASM
run: yarn fulltext-search
- uses: actions/cache@v3
id: nextjs-cache
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Build project
run: yarn build
- name: Export Static Assets
run: yarn export
- name: Push to gh-pages branch
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
commit_message: 'chore: deploy to gh-pages'
release:
runs-on: ubuntu-20.04
needs: ['deploy']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- uses: actions/cache@v3
id: yarn-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Config git user
run: |
git config --global user.email "$GIT_USER_EMAIL"
git config --global user.name "$GIT_USER_NAME"
# - name: Dry Run
# if: ${{ github.ref != 'refs/heads/main'}}
# run: yarn release --dry-run
- name: Release
if: ${{ github.ref == 'refs/heads/main' }}
run: yarn release --ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}