-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
114 lines (94 loc) · 2.9 KB
/
ci.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: ci
on:
- push
- pull_request
jobs:
test:
strategy:
matrix:
node-version: [ 14.x ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
# checkout the code
- name: Checkout
uses: actions/checkout@v2
# verify the version in package.json matches the release tag
- name: Version
uses: tcurdt/action-verify-version-npm@master
# setup the node version
- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# cache node_modules if we can
- name: Cache
id: cache-modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
# ottherweise run install
- name: Install
if: steps.cache-modules.outputs.cache-hit != 'true'
run: npm install
# run tests
- name: Test
run: npm test
# create github release
release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [ test ]
runs-on: ubuntu-latest
steps:
# create github release (which triggers the release workflows)
- name: Release
uses: softprops/action-gh-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.PAT }}
# # publish latest master or release to dockerhub
# dockerhub:
# if: github.event_name == 'push'
# needs: [ test ]
# runs-on: ubuntu-latest
# env:
# image: ${{ secrets.DOCKERHUB_USERNAME }}/gun
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Login
# env:
# DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
# DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
# run: echo -n ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
# - name: Build
# run: |
# echo "SHA=$GITHUB_SHA"
# docker build --build-arg SHA=$GITHUB_SHA \
# BUILD_DATE=$(date +'%Y-%m-%dT%H:%M:%S') \
# VCS_REF=${GITHUB_REF} \
# VCS_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} \
# VERSION=${GITHUB_REF##*/} \
# SHA=$GITHUB_SHA \
# --label "SHA=$GITHUB_SHA" \
# --tag ${{ env.image }}:${GITHUB_REF##*/} \
# --tag ${{ env.image }}:latest \
# .
# - name: Push
# run: docker push ${{ env.image }}
# publish release to npm
npm:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [ test ]
# needs: [ release ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Publish
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN
npm install
npm publish --access=public