Merge pull request #8 from lippoliv/dependabot/github_actions/docker/… #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Publish Docker image | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
jobs: | |
build-go: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 | |
- name: Setup Go | |
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # 5.0.0 | |
with: | |
go-version: '1.21.5' | |
- name: Install dependencies | |
working-directory: src | |
run: go get -v . | |
- name: Build go application | |
working-directory: src | |
run: go build -o assistant | |
- name: upload-artifact | |
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # 4.0.0 | |
with: | |
name: go-build | |
path: src/assistant | |
build-docker: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
needs: | |
- build-go | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 | |
- name: download-artifact | |
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # 4.1.0 | |
with: | |
name: go-build | |
path: src/assistant | |
- name: Log in to Docker Hub | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # 3.0.0 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@dbef88086f6cef02e264edb7dbf63250c17cef6c #5.5.0 | |
with: | |
images: lippertsweb/billbee-house-number-assistant | |
tags: | | |
# set latest tag for default branch | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=semver,pattern={{version}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # 5.1.0 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |