Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/actions/netlify/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy to Netlify

description: Deploy to Netlify

inputs:
publish-dir:
description: e.g. "dist", "_site"
required: true
netlify-auth-token:
description: Required The token to use for authentication.
required: true
netlify-site-id:
description: API site ID of the site you wanna work on
required: true

outputs:
netlify-url:
value: ${{ steps.result.outputs.deploy-url }}
description: the URL of the draft site that Netlify provides

runs:
using: composite
steps:
- uses: actions/checkout@v4
with:
clean: false
- name: Deploy to Netlify
id: netlify
# FYI: https://github.com/netlify/actions/pull/65
uses: South-Paw/action-netlify-cli@v2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このリポジトリで使われている nwtgck/actions-netlify だと、ドット始まりのフォルダがうまくアップロードできなかったので、 別のGithub Actionsを使いました。

最初はNetlifyの公式アクションを使おうと思ったんですが、ちょっとメンテされてないのかWarningが出ていた( netlify/actions#65 )ので、それが修正された South-Paw/action-netlify-cli を使ってます。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

似たような機能のactionを複数利用していると、分かりにくなるのでこの機会に、CIでのtest deployを行なっているactionもSouth-Paw/action-netlify-cli に修正していただけると助かります🙏

- uses: nwtgck/actions-netlify@v1.0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • コメントで使っているアクションがPRに対してコメントいれるアクションだったこと
  • pushしたコミットごとにデプロイのコメントがつくとSlackの通知的に邪魔だったりPRから探すのに不便

だったので、pull request作成時のみDeploy Previewを作成するように振る舞いを変更しました。(もとの振る舞いのほうがよさそうなら戻します)
↓の用な感じでPRを作成・更新するとDeploy Previewについてのコメントがされて確認できます。
#183 (comment)

with:
args: 'deploy --json --dir \"${{ inputs.publish-dir }}\" --message \"VRT report [${{ github.sha }}]\"'
env:
NETLIFY_AUTH_TOKEN: ${{ inputs.netlify-auth-token }}
NETLIFY_SITE_ID: ${{ inputs.netlify-site-id }}
- name: Set outputs
id: result
shell: bash
run: echo "deploy-url=${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).deploy_url }}" >> "$GITHUB_OUTPUT"
22 changes: 22 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Setup

description: Setup environment

runs:
using: composite
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- name: Cache node modules
id: node_modules_cache_id
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- if: ${{ steps.node_modules_cache_id.outputs.cache-hit != 'true' }}
Comment thread
YuMuuu marked this conversation as resolved.
shell: bash
run: npm ci
101 changes: 28 additions & 73 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,96 +2,51 @@ name: CD

on:
push:
branches:
- master
branches:
- master

jobs:
build:
name: Build
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.16.0]

steps:
- uses: actions/checkout@v2
name: Check out repository code
- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@preview
name: Cache ~/.npm/
with:
path: '~/.npm/'
key: ${{ runner.os }}-projectname-${{ hashFiles(format('{0}{1}', github.workspace, 'package-lock.json')) }}
restore-keys:
${{ runner.os }}-projectname-
- run: npm ci
- run: npm run build
name: Run build
- uses: nwtgck/actions-netlify@v1.2.3
name: deploy to netlify
with:
publish-dir: './out'
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- uses: actions/checkout@v4
name: Check out repository code
- uses: ./.github/actions/setup
- run: npm run build
name: Run build
- uses: nwtgck/actions-netlify@v1.2.3
name: deploy to netlify
with:
publish-dir: './out'
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

lint:
name: Lint
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.17.0]

steps:
- uses: actions/checkout@v2
name: Check out repository code
- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@preview
name: Cache ~/.npm/
with:
path: '~/.npm/'
key: ${{ runner.os }}-projectname-${{ hashFiles(format('{0}{1}', github.workspace, 'package-lock.json')) }}
restore-keys:
${{ runner.os }}-projectname-
- run: npm ci
- run: npm run lint
name: Run lint
- uses: actions/checkout@v4
name: Check out repository code
- uses: ./.github/actions/setup
- run: npm run lint
name: Run lint

deploy:
name: deploy
needs: [build, lint]
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.16.0]

steps:
- uses: actions/checkout@v2
name: Check out repository code
- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@preview
name: Cache ~/.npm/
with:
path: '~/.npm/'
key: ${{ runner.os }}-projectname-${{ hashFiles(format('{0}{1}', github.workspace, 'package-lock.json')) }}
restore-keys:
${{ runner.os }}-projectname-
- run: npm ci
- run: npm run build # build時間が長くなってきたらdeploy jobにbuildを含めないでartifact経由で取得するように変更する
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
- uses: actions/checkout@v4
name: Check out repository code
- uses: ./.github/actions/setup
- run: npm run build # build時間が長くなってきたらdeploy jobにbuildを含めないでartifact経由で取得するように変更する
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
74 changes: 22 additions & 52 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,38 @@ name: CI

on:
push:
branches:
- '**'
- '!master'
- '!gh-pages'
branches:
- '**'
- '!master'
- '!gh-pages'

jobs:
build:
name: Build
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.16.0]

steps:
- uses: actions/checkout@v2
name: Check out repository code
- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@preview
name: Cache ~/.npm/
with:
path: '~/.npm/'
key: ${{ runner.os }}-projectname-${{ hashFiles(format('{0}{1}', github.workspace, 'package-lock.json')) }}
restore-keys:
${{ runner.os }}-projectname-
- run: npm ci
- run: npm run build
name: Run build
- uses: nwtgck/actions-netlify@v1.0
name: deploy to netlify
with:
publish-dir: './out'
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- uses: actions/checkout@v4
name: Check out repository code
- uses: ./.github/actions/setup
- run: npm run build
name: Run build
- uses: nwtgck/actions-netlify@v1.0
name: deploy to netlify
with:
publish-dir: './out'
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

lint:
name: Lint
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.16.0]

steps:
- uses: actions/checkout@v2
name: Check out repository code
- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@preview
name: Cache ~/.npm/
with:
path: '~/.npm/'
key: ${{ runner.os }}-projectname-${{ hashFiles(format('{0}{1}', github.workspace, 'package-lock.json')) }}
restore-keys:
${{ runner.os }}-projectname-
- run: npm ci
- run: npm run lint
name: Run lint
- uses: actions/checkout@v4
name: Check out repository code
- uses: ./.github/actions/setup
- run: npm run lint
name: Run lint
48 changes: 48 additions & 0 deletions .github/workflows/vrt.yml
Comment thread
YuMuuu marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Visual Regression Testing

on:
pull_request:
types: [opened, synchronize]

jobs:
test:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.45.1-jammy
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Install Japanese fonts
run: |
apt-get update
apt-get purge -y fonts-wqy-zenhei fonts-ipafont-gothic
apt-get install -y fonts-noto-cjk-extra
fc-cache -fv
Comment thread
YuMuuu marked this conversation as resolved.
- uses: ./.github/actions/setup
- name: Run visual tests
continue-on-error: true
id: vrt
run: npm run test:vrt
- uses: ./.github/actions/netlify
id: netlify
timeout-minutes: 1
with:
publish-dir: ./.reg
netlify-auth-token: ${{ secrets.NETLIFY_AUTH_TOKEN }}
netlify-site-id: ${{ secrets.NETLIFY_SITE_ID }}
- if: ${{ steps.vrt.outcome == 'success' }}
name: Comment PR if success
uses: thollander/actions-comment-pull-request@v2
with:
message: |
**✨✨ That's perfect, there is no visual difference! ✨✨**

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reg-suit の通知プラグインのテキストを流用

You can check [this report](${{ steps.netlify.outputs.netlify-url }}) out here.
comment_tag: test-report-vrt
- if: ${{ steps.vrt.outcome == 'failure' }}
name: Comment PR if failure
uses: thollander/actions-comment-pull-request@v2
with:
message: |
**reg-suit detected visual differences.**
Check [this report](${{ steps.netlify.outputs.netlify-url }}), and review them.
comment_tag: test-report-vrt
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ yarn-error.log*

# vercel
.vercel
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

# vrt
.reg
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.16.0
20.16.0
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
Loading