78 lines (69 loc) 路 2.16 KB
/
ci.yaml
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
78
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test_node:
runs-on: ubuntu-latest
if: ${{ !github.event.created }}
strategy:
matrix:
node: [ '13', '12', '11', '10', '8' ]
name: Test with Node v${{ matrix.node }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run build
- run: npm run test
trigger_publish:
name: Trigger publish.yaml workflow if package.json version updated ( and secrets.PAT is set ).
runs-on: ubuntu-latest
env:
PAT: ${{secrets.PAT}}
if: github.event_name == 'push' && github.event.head_commit.author.name != 'ts_ci'
needs: test_node
steps:
- name: Get version on branch 'latest'
id: v_latest
uses: garronej/github_actions_toolkit@master
with:
action_name: get_package_json_version
owner: ${{github.repository_owner}}
repo: ${{github.event.repository.name}}
branch: latest
compare_to_version: '0.0.0'
- name: Get version on master
id: v_master
uses: garronej/github_actions_toolkit@master
with:
action_name: get_package_json_version
owner: ${{github.repository_owner}}
repo: ${{github.event.repository.name}}
branch: ${{ github.sha }}
compare_to_version: ${{steps.v_latest.outputs.version || '0.0.0'}}
- name: 'Trigger the ''publish'' workflow if newer version'
if: ${{ !!env.PAT && steps.v_master.outputs.compare_result == '1' }}
uses: garronej/github_actions_toolkit@master
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
action_name: dispatch_event
owner: ${{github.repository_owner}}
repo: ${{github.event.repository.name}}
event_type: publish
client_payload_json: |
${{
format(
'{{"from_version":"{0}","to_version":"{1}","repo":"{2}"}}',
steps.v_latest.outputs.version,
steps.v_master.outputs.version,
github.event.repository.name
)
}}