Uses own logic for generating tags instead of the docker meta action
Closes from Will-Lo/use-certified-gh-docker
@@ -21,10 +21,14 @@ on:
# Publish only on `master`
branches:
- master
-
+ pull_request:
+ branches:
+ - master
+ paths:
+ - 'gobblin-docker/**'
+ - '.github/workflows/docker_build_publish.yaml'
release:
- tags:
- - 'v*'
+ types: [published, edited]
env:
IMAGE_NAME: apache/gobblin
@@ -36,16 +40,22 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v2
+ - name: Build Docker Tag
+ id: build_tag
+ run: |
+ SHA=`echo ${{ github.sha }} | head -c 7`
+ if [[ ${{ github.event_name }} == 'release' ]]; then
+ TAG="${{ env.IMAGE_NAME }}:sha-$SHA, ${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}, ${{ env.IMAGE_NAME }}:latest"
+ else
+ TAG="${{ env.IMAGE_NAME }}:sha-$SHA"
+ fi
+ echo "tag=$TAG"
+ echo "::set-output name=tag::$TAG"
- 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
+ if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -59,6 +69,6 @@ jobs:
- name: Build Images and Publish
uses: docker/build-push-action@v2
with:
- tags: ${{ steps.docker_meta.outputs.tags }}
- push: true
+ tags: ${{ steps.build_tag.outputs.tag }}
+ push: ${{ github.event_name != 'pull_request' }}
file: ./gobblin-docker/gobblin/alpine-gobblin-latest/Dockerfile
\ No newline at end of file
