forked from kyle-ruan/react-algolia
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (61 loc) · 1.64 KB
/
publish-npm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: publish-npm
on:
workflow_dispatch:
push:
paths:
- '**'
- .github/workflows/publish-npm.yml
branches:
- 'master'
pull_request:
paths:
- '**'
- .github/workflows/publish-npm.yml
branches:
- 'master'
defaults:
run:
working-directory: .
jobs:
validate-npm:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # organization secret
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Mark git checkout as safe
run: git config --global --add safe.directory $GITHUB_WORKSPACE
- uses: actions/setup-node@v3
with:
node-version-file: .node-version
cache: yarn
cache-dependency-path: yarn.lock
- name: install dependencies
run: |
echo //registry.npmjs.org/:_authToken=$NPM_TOKEN > .npmrc
yarn config set unsafe-perm true
yarn install --frozen-lockfilec
- name: Validate NPM
run: yarn validate
publish-npm:
if: github.event.ref == 'refs/heads/master'
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # organization secret
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master
- name: Mark git checkout as safe
run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: install dependencies
run: |
echo //registry.npmjs.org/:_authToken=$NPM_TOKEN > .npmrc
yarn config set unsafe-perm true
yarn install --frozen-lockfilec
- name: Publish to NPM
run: npm publish