name: Build and Publish Docker image
on:
  push:
    # Publish only on `master`
    branches:
      - master

    # Publish `v1.2.3` tags as releases.
    tags:
      - v*

env:
  IMAGE_NAME: apache/gobblin

jobs:
  build_and_push_to_registry:
    name: Build docker images and publish to DockerHub
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repo
        uses: actions/checkout@v2
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: Docker meta
        id: docker_meta
        uses: crazy-max/ghaction-docker-meta@v1
        with:
          images: ${{ env.IMAGE_NAME }} # list of Docker images to use as base name for tags
          tag-sha: true # add git short SHA as Docker tag
      - name: Login to DockerHub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKERHUB_USER }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
#      - name: Login to GitHub Container Registry
#        if: github.event_name != 'pull_request'
#        uses: docker/login-action@v1
#        with:
#          registry: ghcr.io
#          username: ${{ github.repository_owner }}
#          password: ${{ secrets.CR_PAT }}
      - name: Build Images and Publish
        uses: docker/build-push-action@v2
        with:
          tags: ${{ steps.docker_meta.outputs.tags }}, ${{ env.IMAGE_NAME }}:latest
          push: true
          file: ./gobblin-docker/gobblin-standalone/alpine-gobblin-latest/Dockerfile
Create Github Action to automatically build and publish images
[GOBBLIN-1313] Create Github Action to automatically build and publish images

Closes #3151 from Will-Lo/github-action-generate-
docker
