fabiocicerchia/go-proxy-cache

View on GitHub
.github/workflows/docker.yml

Summary

Maintainability
Test Coverage
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Publish Docker image

on:
  release:
    types: [published]

jobs:
  push_to_registry:
    name: Push Docker image to Docker Hub
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repo
        uses: actions/checkout@v2

      - name: Log in to Docker Hub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_HUB_USERNAME }}
          password: ${{ secrets.DOCKER_HUB_TOKEN }}

      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v1

      - name: Build and push (latest)
        id: docker_build_latest
        uses: docker/build-push-action@v2
        with:
          context: ./
          file: ./docker/Dockerfile
          push: true
          tags: ${{ secrets.DOCKER_HUB_USERNAME }}/go-proxy-cache:latest

      - name: Image digest (latest)
        run: echo ${{ steps.docker_build_latest.outputs.digest }}

      - name: Build and push (tag)
        id: docker_build_tag
        uses: docker/build-push-action@v2
        with:
          context: ./
          file: ./docker/Dockerfile
          push: true
          tags: ${{ secrets.DOCKER_HUB_USERNAME }}/go-proxy-cache:${{ github.event.release.tag_name }}

      - name: Image digest (tag)
        run: echo ${{ steps.docker_build_tag.outputs.digest }}