-
Notifications
You must be signed in to change notification settings - Fork 57
62 lines (51 loc) · 1.68 KB
/
test-and-update.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
name: Test and Update dist
on:
pull_request:
branches: [master]
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Set up Repository
uses: actions/checkout@v3
- name: Get Node Version
id: node_version
run: |
node_version=`cat .nvmrc`
echo "::set-output name=node_version::$node_version"
echo "Node Version: $node_version"
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ steps.node_version.outputs.node_version }}
- name: Cache NPM Dependencies
id: cache-npm-dependencies
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Install NPM Dependencies if not cached
if: steps.cache-npm-dependencies.outputs.cache-hit != 'true'
run: |
npm install
- name: Build Action
run: npm run build
- name: Lint Action
run: npm run lint
- name: Test Action
run: npm run test
- name: Package Action
run: npm run package
- name: Commit if dist has changed
run: |
echo "${{ toJson(github) }}"
git config user.name "Github Actions"
git config user.email [email protected]
if [ $(git status dist --porcelain=v1 2>/dev/null | wc -l) != "0" ]; then
git add dist
git commit -m "chore: updated dist with new code"
git push origin HEAD:${{ github.event.pull_request.head.ref }} --force
fi