Skip to content

Commit

Permalink
build: cleanup & more improvements for the release-docker-hub job
Browse files Browse the repository at this point in the history
Signed-off-by: FabioPinheiro <[email protected]>
  • Loading branch information
FabioPinheiro committed Nov 29, 2024
1 parent 1bdc62a commit b35fab3
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions .github/workflows/release-docker-hub.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
name: Release to Docker Hub
# ower: FabioPinheiro
# updated: 2024/11/25
# updated: 2024/11/29
# How to test:
# > git tag v9.9.9
# > git tag --delete v9.9.9
# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN -j build-and-push-docker-images schedule
# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN --workflows '.github/workflows/release-docker-hub.yml' push
# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN -j build-and-push-docker-images schedule
# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN --workflows '.github/workflows/release-docker-hub.yml' push
# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" \
# --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN \
# --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN \
# workflow_dispatch --workflows '.github/workflows/release-docker-hub.yml' --eventpath \
# <( jq -n '{ inputs: { DEPLOYMENT_BRANCH: "v1.0.0" } }' )

# How to push old images from another repo:
# > docker login docker.io -u fmgp -p $DOCKERHUB_FMGP_TOKEN
# > docker login docker.io -u identus -p $DOCKERHUB_IDENTUS_TOKEN
# > docker login docker.io -u $DOCKERHUB_IDENTUS_USERNAME -p $DOCKERHUB_IDENTUS_TOKEN
# > OLD_TAG=ghcr.io/hyperledger/identus-mediator:1.0.0; NEW_TAG=docker.io/identus/identus-mediator:1.0.0; docker buildx imagetools create --tag "$NEW_TAG" "$OLD_TAG"


Expand Down Expand Up @@ -83,28 +80,29 @@ jobs:
fail-fast: false
matrix:
docker:
- # identus # This is a test account
- # identus
registry: docker.io
repository: ${{vars.DOCKERHUB_IDENTUS_USERNAME}}
repository: identus
username: ${{vars.DOCKERHUB_IDENTUS_USERNAME}}
password_name: DOCKERHUB_IDENTUS_TOKEN
tags_noschedule: |
type=semver,pattern={{version}}
type=sha,format=long
type=edge,branch=main
type=raw,value=latest,enable=${{ !startsWith(github.ref, 'refs/tags/v') }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
tags_schedule: |
type=schedule,pattern=nightly,enable={{is_default_branch}}
- # fmgp # My presonal acount also for testing
registry: docker.io
repository: ${{vars.DOCKERHUB_FMGP_USERNAME}}
username: ${{vars.DOCKERHUB_FMGP_USERNAME}}
password_name: DOCKERHUB_FMGP_TOKEN
tags_noschedule: |
type=semver,pattern={{version}},enable={{is_default_branch}}
type=raw,value=latest,enable={{is_default_branch}}
tags_schedule: |
type=schedule,enable={{is_default_branch}}
# TODO to avoid build the image multiple times (matrix) let's create a step that copies the release tags
# - # fmgp # My presonal acount for testing. TODO replace with hyperledger
# registry: docker.io
# repository: fmgp
# username: ${{vars.DOCKERHUB_FMGP_USERNAME}}
# password_name: DOCKERHUB_FMGP_TOKEN
# tags_noschedule: |
# type=semver,pattern={{version}},enable={{is_default_branch}}
# type=raw,value=latest,enable={{is_default_branch}}
# tags_schedule: |
# type=schedule,enable={{is_default_branch}}

steps:
- name: Set test variable
Expand All @@ -129,11 +127,9 @@ jobs:
echo "##################"
echo "#### JOB INFO ####"
echo "##################"
echo "### github.event_name=${{github.event_name}} (Is this type 'schedule'""? ${{ github.event_name == 'schedule' }})"
echo "### matrix.docker.tags_schedule: ${{ matrix.docker.tags_schedule }}"
echo "### matrix.docker.tags_noschedule: ${{ matrix.docker.tags_noschedule }}"
echo "### github.event_name=${{github.event_name}}
echo "### env.META_CONFIG: ${{ env.META_CONFIG }}"
echo "### TAGS: ${{ steps.meta.outputs.tags == '' }}"
echo "### TAGS: is steps.meta.outputs.tags == to ''? ${{ steps.meta.outputs.tags == '' }}"
echo "${{ steps.meta.outputs.tags }}"
echo "### runner: ${{ toJSON(runner) }}"
echo "### github: ${{ toJSON(github) }}"
Expand Down Expand Up @@ -163,9 +159,7 @@ jobs:
username: ${{ matrix.docker.username }}
password: ${{ secrets[matrix.docker.password_name] }}

# TODO FIX These builds the image multiple times (matrix)
- name: Build and push identus-mediator Image
id: push
uses: docker/build-push-action@v6
with:
context: ./docker-artifact/
Expand Down

0 comments on commit b35fab3

Please sign in to comment.