chore(GoReleaser): publish to Docker (#23)

* Create Dockerfile
* Update .goreleaser.yml
* Update .github/workflows/ci.yml
This commit is contained in:
Oskar 2021-10-19 23:20:25 +02:00 committed by GitHub
parent e7005810b8
commit 43e46b5cad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 2 deletions

View File

@ -4,6 +4,7 @@ on:
push:
branches:
- main
pull_request:
permissions:
@ -12,6 +13,7 @@ permissions:
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Repo clone (go mod tidy / gofmt)
if: github.event_name != 'pull_request'
@ -30,14 +32,14 @@ jobs:
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: tidy
- name: Tidy
if: github.event_name != 'pull_request'
run: |
go mod tidy -go=1.17
git add .
git diff-index --quiet HEAD || git commit -m "go mod tidy"
- name: gofmt
- name: GoFmt
if: github.event_name != 'pull_request'
run: |
go fmt ./...
@ -66,6 +68,13 @@ jobs:
with:
fetch-depth: 0
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:

View File

@ -31,3 +31,32 @@ checksum:
name_template: 'md5_checksums.txt'
algorithm: md5
dockers:
- id: amd64
goos: linux
goarch: amd64
goarm: ''
image_templates:
- "medzik/pingbot:latest"
- "medzik/pingbot:{{ .Tag }}"
- "medzik/pingbot:v{{ .Major }}"
- "medzik/pingbot:v{{ .Major }}.{{ .Minor }}"
dockerfile: Dockerfile
use: docker
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
extra_files:
- start.sh

5
Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM alpine
COPY pingbot.out /usr/bin/pingbot
ENTRYPOINT ["/usr/bin/pingbot"]