From 48cb2fbe4828f9936bd815b1c9aaee1193196f7b Mon Sep 17 00:00:00 2001 From: samuelarogbonlo Date: Mon, 23 Jan 2023 13:18:48 +0100 Subject: [PATCH 1/2] Add github workflow to push to Dockerhub --- .github/workflows/docker-hub.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/docker-hub.yml 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 From 8bc13de1cda85d0d2dfdc16572336463bfc802f9 Mon Sep 17 00:00:00 2001 From: samuelarogbonlo Date: Mon, 23 Jan 2023 13:19:01 +0100 Subject: [PATCH 2/2] Add script to build and push Docker image --- scripts/docker-hub-publish.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 scripts/docker-hub-publish.sh 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