name: Publish Docker image to Dockerhub on: push: tags: - '*.*.*' 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 if: github.event_name != 'pull_request' uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v3 with: images: krateng/maloja # generate Docker tags based on the following events/attributes tags: | type=raw,value=latest,enable=${{ endsWith(github.ref, 'master') }} type=ref,event=branch,enable=${{ !endsWith(github.ref, 'master') }} type=semver,pattern={{version}} flavor: | latest=false - name: Build and push Docker image uses: docker/build-push-action@v2 with: context: . push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}