Skip to content

Commit 6f06618

Browse files
authored
Publish image to hub (#25)
1 parent 668a9d8 commit 6f06618

File tree

8 files changed

+65
-14
lines changed

8 files changed

+65
-14
lines changed

.github/workflows/build.yml

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,68 @@ on:
44
push:
55
branches:
66
- master
7+
tags:
8+
- v*
79
pull_request:
810

911
jobs:
10-
test:
12+
image:
1113
runs-on: ubuntu-latest
1214
env:
13-
DOCKER_TAG: ${{ github.sha }}
15+
DOCKERHUB_USERNAME: levonet
1416
steps:
17+
1518
- name: Checkout
1619
uses: actions/checkout@v2
17-
- name: Build the Docker image
18-
run: docker build -t levonet/nginx:${DOCKER_TAG} .
20+
21+
- name: Docker meta
22+
id: meta
23+
uses: docker/metadata-action@v3
24+
with:
25+
images: levonet/nginx
26+
tags: |
27+
type=ref,event=branch
28+
type=ref,event=pr
29+
type=semver,pattern={{version}}
30+
type=semver,pattern={{major}}.{{minor}}
31+
flavor: |
32+
latest=auto
33+
suffix=-alpine,onlatest=false
34+
35+
- name: Login to DockerHub
36+
if: ${{ github.event_name != 'pull_request' }}
37+
uses: docker/login-action@v1
38+
with:
39+
username: ${{ env.DOCKERHUB_USERNAME }}
40+
password: ${{ secrets.DOCKERHUB_TOKEN }}
41+
42+
- name: Build and export to Docker
43+
uses: docker/build-push-action@v2
44+
with:
45+
context: .
46+
load: true
47+
tags: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
48+
1949
- name: Run test
50+
env:
51+
DOCKER_IMAGE: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
2052
run: |
2153
cd test
22-
make
54+
make test
55+
56+
- name: Build and push
57+
if: ${{ github.event_name != 'pull_request' }}
58+
uses: docker/build-push-action@v2
59+
with:
60+
context: .
61+
push: true
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
64+
65+
- name: Docker Hub Description
66+
if: ${{ github.event_name != 'pull_request' }}
67+
uses: peter-evans/dockerhub-description@v2
68+
with:
69+
username: ${{ env.DOCKERHUB_USERNAME }}
70+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
71+
repository: levonet/nginx

test/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
DOCKER_TAG ?= latest
2+
DOCKER_IMAGE ?= levonet/nginx:$(DOCKER_TAG)
23
TESTS = check jaeger njs proxy_connect redis sticky
34

4-
.PHONY: all build clean $(TESTS)
5-
all: build $(TESTS)
5+
.PHONY: all build test clean $(TESTS)
6+
all: build test
7+
test: $(TESTS)
68

79
build:
8-
docker build -t levonet/nginx:$(DOCKER_TAG) ..
10+
docker build -t $(DOCKER_IMAGE) ..
911

1012
$(TESTS):
1113
cd $@; \

test/check/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3"
22

33
services:
44
nginx:
5-
image: levonet/nginx:${DOCKER_TAG:-latest}
5+
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
66
ports:
77
- "8000:8000"
88
volumes:

test/jaeger/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3"
22

33
services:
44
nginx:
5-
image: levonet/nginx:${DOCKER_TAG:-latest}
5+
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
66
ports:
77
- "8000:8000"
88
volumes:

test/njs/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3"
22

33
services:
44
nginx:
5-
image: levonet/nginx:${DOCKER_TAG:-latest}
5+
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
66
ports:
77
- "8000:8000"
88
volumes:

test/proxy_connect/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3"
22

33
services:
44
nginx:
5-
image: levonet/nginx:${DOCKER_TAG:-latest}
5+
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
66
ports:
77
- "3128:3128"
88
volumes:

test/redis/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3"
22

33
services:
44
nginx:
5-
image: levonet/nginx:${DOCKER_TAG:-latest}
5+
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
66
ports:
77
- "8000:8000"
88
volumes:

test/sticky/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3"
22

33
services:
44
nginx:
5-
image: levonet/nginx:${DOCKER_TAG:-latest}
5+
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
66
ports:
77
- "8000:8000"
88
volumes:

0 commit comments

Comments
 (0)