-
Notifications
You must be signed in to change notification settings - Fork 8
61 lines (48 loc) · 1.31 KB
/
test_and_publish_docker_image.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
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
name: ci
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Use Node.js 14.x
uses: actions/setup-node@master
with:
node-version: 14.x
- run: npm ci
- run: npm run lint
- run: npm run test
build_and_publish_docker_image:
needs: test
runs-on: ubuntu-latest
env:
IMAGE: italia/developers-italia-onboarding
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get Docker image tags
run: |
TAGS=${IMAGE}:$(echo ${GITHUB_REF##*/})
TAGS="$TAGS,${IMAGE}:${GITHUB_SHA::8}"
echo "TAGS=${TAGS}" >> $GITHUB_ENV
- name: Add latest tag to Docker image on release
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAGS=$(echo "${{ env.TAGS }}")
TAGS="$TAGS,${IMAGE}:latest"
echo "TAGS=${TAGS}" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ env.TAGS }}