-
Notifications
You must be signed in to change notification settings - Fork 15
75 lines (61 loc) · 2.22 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
name: Continuous Integration
on:
push:
branches:
- '*'
tags-ignore:
- '*'
pull_request:
workflow_dispatch:
jobs:
node14:
name: Build & Test & Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get version and use it in package.json
run: |
VERSION=$(git describe | sed 's/^v//')
echo "::set-output name=VERSION::$VERSION"
sed -i "s/0.0.0/$VERSION/g" package.json
cat package.json
id: version
- name: Enable Docker Layer Caching
uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
- name: Build Docker Image
run: docker build --tag slimapi/apib2json:"$GITHUB_SHA" .
- name: Start Docker Container
run: |
docker run --rm --detach --entrypoint=/bin/sh --name "$GITHUB_SHA" slimapi/apib2json:"$GITHUB_SHA" -c 'while true; do sleep 1; done;'
docker exec "$GITHUB_SHA" npm install --only=dev
- name: Check Coding Standard
run: docker exec "$GITHUB_SHA" npm run lint
- name: Run Tests & Code Coverage
run: |
docker exec "$GITHUB_SHA" npm run coverage
docker exec "$GITHUB_SHA" cat coverage/clover.xml > coverage.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2.0.2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push to DockerHub (VERSION)
run: |
docker tag slimapi/apib2json:"$GITHUB_SHA" slimapi/apib2json:${{ steps.version.outputs.VERSION }}
docker push slimapi/apib2json:${{ steps.version.outputs.VERSION }}
- name: Push to DockerHub (LATEST)
if: github.ref == 'refs/heads/master'
run: |
docker tag slimapi/apib2json:"$GITHUB_SHA" slimapi/apib2json:latest
docker push slimapi/apib2json:latest
- name: NPM Publish (MASTER)
if: github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}