-
-
Notifications
You must be signed in to change notification settings - Fork 310
76 lines (63 loc) · 2.42 KB
/
docker.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
# Triggers a Docker workflow on push events and PRs but
# pushes to DockerHub only for push on the master branch.
# Runs GHC unit tests before DockerHub push.
#
# Author: Just van den Broecke - 2021
#
name: Docker Build ⚓
on:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
# Single job now to build Docker Image, run GHC unit tests, and push to DockerHub
build_test_push:
name: Build, Test and Push Docker Image to DockerHub
runs-on: ubuntu-latest
# v2 https://github.com/docker/build-push-action/blob/master/UPGRADE.md
steps:
- name: Checkout ✅
uses: actions/checkout@v2
- name: Prepare 📦
id: prep
run: |
DOCKER_IMAGE=justb4/jmeter
VERSION="5.5"
TAGS="${DOCKER_IMAGE}:${VERSION}"
echo ::set-output name=image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Show Image Settings 📦
run: echo "IMAGE=${{ steps.prep.outputs.image }} VERSION=${{ steps.prep.outputs.version }} TAGS=${{ steps.prep.outputs.tags }}"
- name: Set up Docker Buildx 📦
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub 📦
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Build only - retain local Image 📦
uses: docker/build-push-action@v2
with:
context: .
load: true
push: false
tags: |
${{ steps.prep.outputs.tags }}
${{ steps.prep.outputs.image }}:latest
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
# - name: TODO Tests with Docker Image ⚙️
# run: docker run --entrypoint "/run-tests.sh" ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.version }}
- name: Push to Docker repo (on Push only) ☁️
if: ${{ github.event_name == 'push' }}
run: docker image push --all-tags ${{ steps.prep.outputs.image }}