name: Publish Docker image

on:
  push:
    branches:
    - master
  release:
    types:
    - published

jobs:
  build-and-push-image:
    name: Push Docker image to GitHub Packages
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
    - name: Check out the repo
      uses: actions/checkout@v2

    - name: Log in to the Container registry
      uses: docker/login-action@v1
      with:
        registry: ghcr.io
        username: ${{ github.actor }}
        password: ${{ secrets.GITHUB_TOKEN }}

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

    - name: Build Docker meta information
      id: meta
      uses: docker/metadata-action@v3
      with:
        images: ghcr.io/harrystech/arthur-redshift-etl/arthur-etl
        tags: |
          type=ref,event=tag
          type=semver,pattern={{major}}.{{minor}}
          type=semver,pattern={{version}}
          type=sha

    - name: Build and push with version tags
      id: docker_build
      if: ${{ github.event_name == 'release' && github.event.release.tag_name != '' }}
      uses: docker/build-push-action@v2
      with:
        context: .
        labels: ${{ steps.meta.outputs.labels }}
        push: ${{ github.event.action == 'published' }}
        tags: ${{ steps.meta.outputs.tags }}

name: Publish Docker image

on:
  push:
    branches:
    - master
    - next
  release:
    types:
    - published

jobs:
  build-and-push-image:
    name: Push Docker image to GitHub Packages
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
    - name: Check out the repo
      uses: actions/checkout@v2

    - name: Log in to the Container registry
      uses: docker/login-action@v1
      with:
        registry: ghcr.io
        username: ${{ github.actor }}
        password: ${{ secrets.GITHUB_TOKEN }}

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

    - name: Build Docker meta information
      id: meta
      uses: docker/metadata-action@v3
      with:
        images: ghcr.io/harrystech/arthur-redshift-etl/arthur-etl
        tags: |
          type=ref,event=tag
          type=semver,pattern={{major}}.{{minor}}
          type=semver,pattern={{version}}
          type=sha

    - name: Build and push with version tags
      id: docker_build
      if: ${{ github.event_name == 'release' && github.event.release.tag_name != '' }}
      uses: docker/build-push-action@v2
      with:
        context: .
        labels: ${{ steps.meta.outputs.labels }}
        push: ${{ github.event.action == 'published' }}
        tags: ${{ steps.meta.outputs.tags }}

Enable publishing pre-releases from next
Enable publishing pre-releases from next
