forked from kentcdodds/kcd-scripts
-
Notifications
You must be signed in to change notification settings - Fork 4
74 lines (57 loc) · 1.8 KB
/
validate.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
name: Validate Code
on: pull_request
jobs:
validate:
runs-on: ubuntu-latest
strategy:
matrix:
# Test with Node.js v14 (LTS), v16 (LTS), and v18
node: [14.x, 16.x, 18.x]
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: install dependencies
run: npm install --no-save
- run: npm run build
- name: lint js
run: npm run lint
- name: run tests
run: npm run test
env:
CI: true
pr-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: install dependencies
run: npm install --no-save
- run: npm run build
- name: publish to npm
id: pr-publish
run: |
version="0.0.0-PR-${PR}--$(echo ${SHA} | cut -c -7)"
npm version $version --no-git-tag-version
npm publish --access public --tag pr
echo "::set-output name=pr_version::$version"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
PR: ${{ github.event.number }}
SHA: ${{ github.event.pull_request.head.sha }}
- uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🚀 PR version published: `${{ steps.pr-publish.outputs.pr_version }}`'
})