Skip to content

Commit

Permalink
[mod] add docker push workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dohq committed Mar 27, 2021
1 parent a2684e4 commit ac66d76
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: docker-push

on:
push:
tags:
- 'v*'

jobs:
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- id: get_version
uses: battila7/get-version-action@v2

- name: Build and Push
env:
REPOSITORY: dohq/dockerhub_ratelimit_exporter
VERSION: ${{ steps.get_version.outputs.version-without-v }}
DOCKER_BUILDKIT: 1
run: |
make container_build
make container_cache
make container_push
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@

# End of https://www.toptal.com/developers/gitignore/api/go
dist/
dockerhub_ratelimit_exporter
26 changes: 24 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
IMAGE_NAME=$(REPOSITORY):$(VERSION)
LATEST=$(REPOSITORY):latest
CACHE=$(REPOSITORY):cache-latest

container_build:
docker build --cache-from=$(CACHE) \
--build-arg=BUILDKIT_INLINE_CACHE=1 \
-t $(IMAGE_NAME) \
-t $(LATEST) .

container_push:
docker push $(IMAGE_NAME)
docker push $(CACHE)

# If necessary, add --target
container_cache:
docker build \
--target=builder \
--build-arg=BUILDKIT_INLINE_CACHE=1 \
-t $(CACHE) .
docker push $(CACHE)

build:
go build
test:
go test -v
go test -v -race ./...
run:
go run *.go
go run .
help:
go run *.go -h

0 comments on commit ac66d76

Please sign in to comment.