diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68bcca2..6c04a12 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/test/Makefile b/test/Makefile index 5cd7180..581046f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -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 $@; \ diff --git a/test/check/docker-compose.yaml b/test/check/docker-compose.yaml index 548fad4..e531438 100644 --- a/test/check/docker-compose.yaml +++ b/test/check/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3" services: nginx: - image: levonet/nginx:${DOCKER_TAG:-latest} + image: ${DOCKER_IMAGE:-levonet/nginx:latest} ports: - "8000:8000" volumes: diff --git a/test/jaeger/docker-compose.yaml b/test/jaeger/docker-compose.yaml index d20337d..dab43e6 100644 --- a/test/jaeger/docker-compose.yaml +++ b/test/jaeger/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3" services: nginx: - image: levonet/nginx:${DOCKER_TAG:-latest} + image: ${DOCKER_IMAGE:-levonet/nginx:latest} ports: - "8000:8000" volumes: diff --git a/test/njs/docker-compose.yaml b/test/njs/docker-compose.yaml index 633549d..82ef4f4 100644 --- a/test/njs/docker-compose.yaml +++ b/test/njs/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3" services: nginx: - image: levonet/nginx:${DOCKER_TAG:-latest} + image: ${DOCKER_IMAGE:-levonet/nginx:latest} ports: - "8000:8000" volumes: diff --git a/test/proxy_connect/docker-compose.yaml b/test/proxy_connect/docker-compose.yaml index c7475cf..30fd7cc 100644 --- a/test/proxy_connect/docker-compose.yaml +++ b/test/proxy_connect/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3" services: nginx: - image: levonet/nginx:${DOCKER_TAG:-latest} + image: ${DOCKER_IMAGE:-levonet/nginx:latest} ports: - "3128:3128" volumes: diff --git a/test/redis/docker-compose.yaml b/test/redis/docker-compose.yaml index ee97e3a..33e5f45 100644 --- a/test/redis/docker-compose.yaml +++ b/test/redis/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3" services: nginx: - image: levonet/nginx:${DOCKER_TAG:-latest} + image: ${DOCKER_IMAGE:-levonet/nginx:latest} ports: - "8000:8000" volumes: diff --git a/test/sticky/docker-compose.yaml b/test/sticky/docker-compose.yaml index 347c7b7..59687c6 100644 --- a/test/sticky/docker-compose.yaml +++ b/test/sticky/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3" services: nginx: - image: levonet/nginx:${DOCKER_TAG:-latest} + image: ${DOCKER_IMAGE:-levonet/nginx:latest} ports: - "8000:8000" volumes: