Add workflow to publish Docker image to dockerhub

This commit is contained in:
Ken Hibino 2021-04-08 07:07:36 -07:00
parent 20e46b6f2a
commit 8a0e8dfdf5
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,44 @@
name: Publish Docker image
on:
push:
branches:
- "master"
tags:
- "v*"
pull_request:
branches:
- "master"
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker meta
id: meta
uses: crazy-max/ghaction-docker-meta@v2
with:
images: hibiken/asynqmon
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

View File

@ -36,7 +36,7 @@ RUN go mod download
COPY . .
# Copy frontend static files from /static to the root folder of the backend container.
COPY --from=frontend ["/static/build", "/ui/build"]
COPY --from=frontend ["/static/build", "ui/build"]
# Set necessary environmet variables needed for the image and build the server.
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64