From 0cdc1adc47a4de250c3abf0afc0fabc56c4fb8ff Mon Sep 17 00:00:00 2001 From: binhex Date: Sat, 30 Jan 2021 21:18:11 +0000 Subject: [PATCH] add in github workflows --- .../docker-manual-triggered-test.yml | 50 ++++++++++++++++ .../workflows/docker-tag-triggered-prod.yml | 59 +++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 .github/workflows/docker-manual-triggered-test.yml create mode 100644 .github/workflows/docker-tag-triggered-prod.yml diff --git a/.github/workflows/docker-manual-triggered-test.yml b/.github/workflows/docker-manual-triggered-test.yml new file mode 100644 index 0000000..1695a61 --- /dev/null +++ b/.github/workflows/docker-manual-triggered-test.yml @@ -0,0 +1,50 @@ +name: docker-manual-triggered-test + +on: + workflow_dispatch: + inputs: + tags: + description: 'Enter tag name for test/dev image' + default: 'test' + +jobs: + gcr-dockerhub-build-publish: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + - + name: Show Runners environment (debug) + shell: bash + run: export + - + name: Build and Push to GCR and Docker Hub + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ github.event.inputs.tags }} + ghcr.io/${{ github.repository }}:${{ github.event.inputs.tags }} diff --git a/.github/workflows/docker-tag-triggered-prod.yml b/.github/workflows/docker-tag-triggered-prod.yml new file mode 100644 index 0000000..69d0331 --- /dev/null +++ b/.github/workflows/docker-tag-triggered-prod.yml @@ -0,0 +1,59 @@ +name: docker-tag-triggered-prod + +on: + push: + tags: + - '*' + +jobs: + gcr-dockerhub-build-publish: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + - + name: Show Runners environment (debug) + shell: bash + run: export + - + name: Identify GitHub tag name + shell: bash + # get tag name from runners environment 'GITHUB_REF' and then use bash substring + # to strip out '+' symbol - required due to gcr not supporting this as a tag + # name (docker hub does support it). + # note if push is NOT triggered by tag then 'GITHUB_REF' will be the branch name. + run: echo "##[set-output name=tag;]$(tag_name=${GITHUB_REF#refs/tags/} && echo "${tag_name//+/-}")" + id: identify_tag + - + name: Build and Push to GCR and Docker Hub + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:latest + ${{ github.repository }}:${{ steps.identify_tag.outputs.tag }} + ghcr.io/${{ github.repository }}:latest + ghcr.io/${{ github.repository }}:${{ steps.identify_tag.outputs.tag }}