chore: Update NODE_ENV environment variable in GitHub Actions workflow #33
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: Build and Deploy to GitHub Pages | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
pages: write | |
id-token: write | |
contents: write | |
jobs: | |
# セットアップジョブ | |
setup: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 20 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache yarn dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn install | |
# スマートコントラクトをテストするジョブ | |
test-smartcontract: | |
runs-on: ubuntu-latest | |
needs: setup | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 20 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache yarn dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn install | |
- name: Test Smart Contract | |
run: yarn backend test | |
# ビルドしてGitHub Pagesにデプロイするジョブ | |
build-to-deploy: | |
runs-on: ubuntu-latest | |
needs: setup | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 20 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache yarn dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn install | |
- name: Build | |
run: yarn frontend build | |
env: | |
NEXT_PUBLIC_APP_ICON: ${{ secrets.NEXT_PUBLIC_APP_ICON }} | |
NEXT_PUBLIC_WALLET_URL: ${{ secrets.NEXT_PUBLIC_WALLET_URL }} | |
NEXT_PUBLIC_RPC_URL: ${{ secrets.NEXT_PUBLIC_RPC_URL }} | |
DEFENDER_API_KEY: ${{ secrets.DEFENDER_API_KEY }} | |
DEFENDER_SECRET_KEY: ${{ secrets.DEFENDER_SECRET_KEY }} | |
NODE_ENV: ${{ secrets.NODE_ENV }} | |
- name: Export Pages Artifact | |
run: yarn frontend export | |
# しかしGitHub Pagesの仕様として_から始まるディレクトリが見えず404となる | |
# つまりHTMLからJSを読み込めなくなるので、これを回避するために.nojekyllファイルをoutディレクトリに作る | |
- name: add nojekyll | |
run: touch ./pkgs/frontend/out/.nojekyll | |
- name: Upload Pages Artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
name: github-pages | |
path: ./pkgs/frontend/out | |
retention-days: 5 | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
with: | |
name: github-pages | |
path: ./pkgs/frontend/out |