Skip to content

update dependencies #12

update dependencies

update dependencies #12

Workflow file for this run

name: docker
on:
pull_request:
push:
branches:
- 'master'
tags:
- 'v*'
workflow_dispatch:
# prevent concurrent workflow runs
# - for pull requests, we only want to build the latest commit
# - for master and tags, we need to run all builds, since containers must be pushed
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
IMAGE_NAME: csang/htecho
jobs:
docker:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build dev image
uses: docker/build-push-action@v4
with:
context: .
file: ./build/dev/Dockerfile
load: true
tags: ${{ env.IMAGE_NAME }}-dev:gha
cache-from: type=gha
cache-to: type=gha,mode=max
-
name: Test dev image
run: >
docker run --rm "$IMAGE_NAME"-dev:gha \
/bin/sh -c 'go test -coverprofile=c.out "./..." && go tool cover -func=c.out'
-
name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push prod image
uses: docker/build-push-action@v4
with:
context: .
file: ./build/prod/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max