name: Publish Image

on:
  push:
    branches: ['master']
    tags: ['*']

env:
  DOCKER_HUB_USER: phlak

jobs:
  build-container:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

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

      - name: Extract Metadata
        id: extract-metadata
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.DOCKER_HUB_USER }}/mumble
          tags: |
            type=raw,value=latest
            type=ref,event=tag

      - name: Build & Push Image
        uses: docker/build-push-action@v2
        with:
          push: true
          tags: ${{ steps.extract-metadata.outputs.tags }}
          labels: ${{ steps.extract-metadata.outputs.labels }}

name: Publish Image

on:
  push:
    branches: ['master']
    tags: ['*']
  pull_request:
    branches: ['master']

env:
  DOCKER_HUB_USER: phlak

jobs:
  build-container:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

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

      - name: Extract Metadata
        id: extract-metadata
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.DOCKER_HUB_USER }}/mumble
          tags: |
            type=raw,value=latest
            type=ref,event=tag

      - name: Build & Push Image
        uses: docker/build-push-action@v2
        with:
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.extract-metadata.outputs.tags }}
          labels: ${{ steps.extract-metadata.outputs.labels }}

Test pull requests in CI
Test pull requests in CI
