1
+ name : CI/CD
2
+ on : push
3
+ jobs :
4
+ setup :
5
+ name : setup
6
+ runs-on : ubuntu-latest
7
+ steps :
8
+ - name : Dump GitHub context
9
+ env :
10
+ GITHUB_CONTEXT : ${{ toJson(github) }}
11
+ run : echo "$GITHUB_CONTEXT"
12
+ - name : Checkout
13
+ uses : actions/checkout@v2
14
+ - name : Setup
15
+ uses : actions/setup-node@v1
16
+ with :
17
+ node-version : ' 10.x'
18
+ - uses : actions/cache@v1
19
+ id : yarn-cache
20
+ with :
21
+ path : node_modules
22
+ key : ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
23
+ restore-keys : |
24
+ ${{ runner.os }}-node_modules-
25
+ - name : Install
26
+ if : steps.yarn-cache.outputs.cache-hit != 'true'
27
+ run : yarn install
28
+
29
+ test :
30
+ name : Test
31
+ runs-on : ubuntu-latest
32
+ needs : setup
33
+ steps :
34
+ - name : Checkout
35
+ uses : actions/checkout@v2
36
+ - name : Setup
37
+ uses : actions/setup-node@v1
38
+ with :
39
+ node-version : ' 10.x'
40
+ - uses : actions/cache@v1
41
+ id : yarn-cache
42
+ with :
43
+ path : node_modules
44
+ key : ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
45
+ restore-keys : |
46
+ ${{ runner.os }}-node_modules-
47
+ - name : Install
48
+ if : steps.yarn-cache.outputs.cache-hit != 'true'
49
+ run : yarn install
50
+ - name : test
51
+ run : yarn test
52
+
53
+ notify :
54
+ name : Notify
55
+ runs-on : ubuntu-latest
56
+ if : always()
57
+ needs :
58
+ - test
59
+ - setup
60
+ - publish
61
+ steps :
62
+ - uses : technote-space/workflow-conclusion-action@v1
63
+ - uses : 8398a7/action-slack@v3
64
+ with :
65
+ status : ${{ env.WORKFLOW_CONCLUSION }}
66
+ fields : repo,message,commit,author,action,eventName,ref,workflow # selectable (default: repo,message)
67
+ env :
68
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
69
+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
70
+ if : always()
71
+
72
+ publish :
73
+ name : Publish
74
+ if : contains(github.ref, 'refs/tags')
75
+ needs : test
76
+ runs-on : ubuntu-latest
77
+ steps :
78
+ - name : Checkout
79
+ uses : actions/checkout@v2
80
+ - name : Setup
81
+ uses : actions/setup-node@v1
82
+ with :
83
+ node-version : ' 10.x'
84
+ - uses : filipstefansson/set-npm-token-action@v1
85
+ with :
86
+ token : ${{ secrets.NPM_TOKEN }}
87
+ - name : Publish beta
88
+ if : contains(github.ref, 'beta')
89
+ run : yarn publish --tag beta
90
+ - name : Publish
91
+ if : " !contains(github.ref, 'beta')"
92
+ run : yarn publish
93
+ - name : Generate Changelog
94
+ # this command extracts info about particular version from the changelog
95
+ run : |
96
+ awk -v ver=${GITHUB_REF##*/} '
97
+ /^## Version / { if (p) { exit }; if ($3 == ver) { p=1; next} } p && NF
98
+ ' CHANGELOG.md > changelog-message.txt
99
+ - name : Release
100
+ with :
101
+ body_path : changelog-message.txt
102
+ prerelease : contains(github.ref, 'beta')
103
+ uses : softprops/action-gh-release@v1
104
+ env :
105
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
106
+
107
+
0 commit comments