simplify docker action

This commit is contained in:
Shirshanka Das 2021-02-06 15:22:52 -08:00 committed by Shirshanka Das
parent 76a9564a6f
commit e80ebf180c
2 changed files with 35 additions and 56 deletions

View File

@ -1,56 +0,0 @@
name: datahub-ingest docker
on:
push:
branches:
- main
paths-ignore:
- 'docs/**'
- '**.md'
pull_request:
branches:
- main
paths:
- 'docker/**'
- '.github/workflows/docker-frontend.yml'
paths_ignore:
- '**.md'
- '**.env'
release:
types: [published, edited]
jobs:
setup:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
publish: ${{ steps.publish.outputs.publish }}
steps:
- uses: actions/checkout@v2
- id: tag
run: |
echo "GITHUB_REF: $GITHUB_REF"
TAG=$(echo ${GITHUB_REF} | sed -e 's,refs/heads/master,latest,g' -e 's,refs/tags/,,g' -e 's,refs/pull/\([0-9]*\).*,pr\1,g')
echo "tag=$TAG"
echo "::set-output name=tag::$TAG"
- name: Check whether publishing enabled
id: publish
env:
ENABLE_PUBLISH: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "Enable publish: ${{ env.ENABLE_PUBLISH != '' }}"
echo "::set-output name=publish::${{ env.ENABLE_PUBLISH != '' }}"
build-and-publish-dockerhub:
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v2
- uses: docker/build-push-action@v1
env:
DOCKER_BUILDKIT: 1
with:
dockerfile: ./docker/Dockerfile
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: acryldata/designpartners
tags: ${{ needs.setup.outputs.tag }}
push: ${{ needs.setup.outputs.publish == 'true' }}

View File

@ -0,0 +1,35 @@
name: datahub-ingest docker
on:
push:
branches:
- main
paths-ignore:
- 'docs/**'
- '**.md'
pull_request:
branches:
- main
paths:
- 'docker/**'
- '.github/workflows/docker-ingest.yml'
paths_ignore:
- '**.md'
- '**.env'
release:
types: [published, edited]
jobs:
push_to_registries:
name: Push Docker image to repo
runs-on: ubuntu-latest
steps:
- name: Check out the repo
- uses: actions/checkout@v2
- name: Push to Docker Hub
- uses: docker/build-push-action@v1
- with:
dockerfile: ./docker/Dockerfile
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: acryldata/designpartners
tag_with_ref: true