Skip to content

.github/workflows/build-and-deploy.yaml #386

.github/workflows/build-and-deploy.yaml

.github/workflows/build-and-deploy.yaml #386

on:
schedule:
- cron: 1 4 * * *
workflow_dispatch:
jobs:
build:
permissions:
contents: write
runs-on: ubuntu-22.04
steps:
- name: メインブランチをチェックアウト
uses: actions/checkout@v3
- name: メインブランチへ60日間コミットがないと、スケジュールされたワークフローが停止するのを防止
# https://docs.github.com/actions/managing-workflow-runs/disabling-and-enabling-a-workflow
uses: gautamkrishnar/keepalive-workflow@790c7f09285a59b09bb578c85e271c6ff2af97c4 #v1.1.0
- uses: actions/setup-node@v3
with:
node-version: '18'
# https://docs.github.com/ja/actions/using-workflows/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit == 'false' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- run: npm ci
- run: npm run build
- name: GitHub Pages用のデータをアップロード
uses: actions/upload-pages-artifact@v1
with:
path: _site/
deploy:
needs: build
permissions:
pages: write
id-token: write
runs-on: ubuntu-22.04
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v2