Adding github actions to build and push docker image

This commit is contained in:
Shirshanka Das 2021-02-02 20:50:00 -08:00 committed by Shirshanka Das
parent 8d74f97713
commit 76a9564a6f
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,56 @@
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' }}