Skip to content

Commit

Permalink
Publish image to hub (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
levonet authored Sep 6, 2021
1 parent 668a9d8 commit 6f06618
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 14 deletions.
59 changes: 54 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,68 @@ on:
push:
branches:
- master
tags:
- v*
pull_request:

jobs:
test:
image:
runs-on: ubuntu-latest
env:
DOCKER_TAG: ${{ github.sha }}
DOCKERHUB_USERNAME: levonet
steps:

- name: Checkout
uses: actions/checkout@v2
- name: Build the Docker image
run: docker build -t levonet/nginx:${DOCKER_TAG} .

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: levonet/nginx
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=auto
suffix=-alpine,onlatest=false
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v1
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and export to Docker
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}

- name: Run test
env:
DOCKER_IMAGE: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
run: |
cd test
make
make test
- name: Build and push
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Docker Hub Description
if: ${{ github.event_name != 'pull_request' }}
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: levonet/nginx
8 changes: 5 additions & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
DOCKER_TAG ?= latest
DOCKER_IMAGE ?= levonet/nginx:$(DOCKER_TAG)
TESTS = check jaeger njs proxy_connect redis sticky

.PHONY: all build clean $(TESTS)
all: build $(TESTS)
.PHONY: all build test clean $(TESTS)
all: build test
test: $(TESTS)

build:
docker build -t levonet/nginx:$(DOCKER_TAG) ..
docker build -t $(DOCKER_IMAGE) ..

$(TESTS):
cd $@; \
Expand Down
2 changes: 1 addition & 1 deletion test/check/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
nginx:
image: levonet/nginx:${DOCKER_TAG:-latest}
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
ports:
- "8000:8000"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion test/jaeger/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
nginx:
image: levonet/nginx:${DOCKER_TAG:-latest}
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
ports:
- "8000:8000"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion test/njs/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
nginx:
image: levonet/nginx:${DOCKER_TAG:-latest}
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
ports:
- "8000:8000"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion test/proxy_connect/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
nginx:
image: levonet/nginx:${DOCKER_TAG:-latest}
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
ports:
- "3128:3128"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion test/redis/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
nginx:
image: levonet/nginx:${DOCKER_TAG:-latest}
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
ports:
- "8000:8000"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion test/sticky/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
nginx:
image: levonet/nginx:${DOCKER_TAG:-latest}
image: ${DOCKER_IMAGE:-levonet/nginx:latest}
ports:
- "8000:8000"
volumes:
Expand Down

0 comments on commit 6f06618

Please sign in to comment.