diff --git a/.github/workflows/docker-hub.yml b/.github/workflows/docker-hub.yml new file mode 100644 index 0000000..eac021b --- /dev/null +++ b/.github/workflows/docker-hub.yml @@ -0,0 +1,30 @@ +name: Docker Hub + +on: + workflow_dispatch: + push: + branches: [ main ] + tags: [ '*' ] + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build and publish + run: | + # If it is a tag: + if [ -z "${GITHUB_REF##refs/tags/*}" ] ; then + ./scripts/docker-hub-publish.sh ${GITHUB_REF#refs/tags/} + else + ./scripts/docker-hub-publish.sh ${GITHUB_SHA} + fi \ No newline at end of file diff --git a/scripts/docker-hub-publish.sh b/scripts/docker-hub-publish.sh new file mode 100644 index 0000000..0351057 --- /dev/null +++ b/scripts/docker-hub-publish.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +VERSION=$1 + +if [[ -z "$1" ]] ; then + echo "Usage: ./scripts/docker-hub-publish.sh VERSION" + exit 1 +fi + +docker build . -t zeitgeistpm/zeitgeist-token-api:$1 -t zeitgeistpm/zeitgeist-token-api:latest +docker push zeitgeistpm/zeitgeist-token-api:$1 +docker push zeitgeistpm/zeitgeist-token-api:latest \ No newline at end of file