Skip to content

Commit d8b4acf

Browse files
authored
Merge pull request #2 from hankei6km/topic/setup-gh-actions
setup-gh-actions
2 parents 2dc65f7 + d2f9ee2 commit d8b4acf

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.github/workflows/npm_pkg.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://docs.github.com/ja/actions/guides/publishing-nodejs-packages
2+
name: Node.js Package
3+
on:
4+
release:
5+
types: [created]
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
environment: npm_pkg
10+
steps:
11+
- uses: actions/checkout@v2
12+
# npm に公開するように .npmrc ファイルを設定する
13+
- uses: actions/setup-node@v2
14+
with:
15+
node-version: '14.x'
16+
registry-url: 'https://registry.npmjs.org'
17+
- run: npm install
18+
# prepublishOnly を外してここで明示的に buiuld の方が良いか
19+
- run: npm publish
20+
env:
21+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# https://github.com/marketplace/actions/run-jest
2+
name: test
3+
on:
4+
push:
5+
branches_ignore:
6+
- master
7+
jobs:
8+
9+
jest:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
node-version: [14.x]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
24+
# https://docs.github.com/ja/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows
25+
- name: Cache node modules
26+
uses: actions/cache@v2
27+
env:
28+
cache-name: cache-node-modules
29+
with:
30+
# npm キャッシュファイルは Linux/macOS の「~/.npm」に保存される
31+
path: ~/.npm
32+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
33+
restore-keys: |
34+
${{ runner.os }}-build-${{ env.cache-name }}-
35+
${{ runner.os }}-build-
36+
37+
- name: Install modules
38+
run: npm install
39+
40+
- name: Run tests
41+
run: npm run test

0 commit comments

Comments
 (0)