-
Notifications
You must be signed in to change notification settings - Fork 5
50 lines (47 loc) · 1.5 KB
/
publish.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
name: Test, Build and Push PushGateway-Cleaner Image
on: [push, pull_request]
jobs:
test:
name: Intgration Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install dependencies
run: npm install
- name: Run Tests (Mocha)
run: npm test
env:
PUSHGATEWAY_URL: http://localhost:9091
build-and-push:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: test
if: contains(github.ref, 'main')
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Extract Version
id: package_version
run: |
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
PACKAGE_VERSION=`echo $PACKAGE_VERSION | sed 's/ *$//g'`
echo PACKAGE_VERSION=$PACKAGE_VERSION
echo "::set-output name=version::$PACKAGE_VERSION"
- name: Print Version
run: echo ${{ steps.package_version.outputs.version}}
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: zooz/pushgateway-cleaner
push: true
tags: latest, version-${{ steps.package_version.outputs.version }}