Skip to content

Commit

Permalink
Publish README to registries (#87)
Browse files Browse the repository at this point in the history
* Publish README to registries

* Allow continuing on failure as we are hitting character limit on dockerhub

---------

Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri authored May 2, 2024
1 parent 706f7b2 commit 623e13a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 10 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
type: string
description: DockerHub organization
default: mahendrapaipuri
docker_hub_registry_provider:
type: string
description: DockerHub registry provider
default: dockerhub
quay_registry:
type: string
description: Quay registry
Expand All @@ -18,6 +22,10 @@ on:
type: string
description: Quay organization
default: mahendrapaipuri
quay_registry_provider:
type: string
description: Quay registry provider
default: quay
push:
paths:
- "go.sum"
Expand Down Expand Up @@ -69,9 +77,11 @@ jobs:
with:
registry: ${{ inputs.docker_hub_registry || 'docker.io' }}
organization: ${{ inputs.docker_hub_organization || 'mahendrapaipuri' }}
registry_provider: ${{ inputs.docker_hub_registry_provider || 'dockerhub' }}
secrets:
login: ${{ secrets.DOCKER_HUB_LOGIN }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
quay_api_token: ${{ secrets.QUAY_API_TOKEN }}

quay:
needs: [build]
Expand All @@ -81,6 +91,8 @@ jobs:
with:
registry: ${{ inputs.quay_registry || 'quay.io' }}
organization: ${{ inputs.quay_organization || 'mahendrapaipuri' }}
registry_provider: ${{ inputs.quay_registry_provider || 'quay' }}
secrets:
login: ${{ secrets.QUAY_LOGIN }}
password: ${{ secrets.QUAY_PASSWORD }}
quay_api_token: ${{ secrets.QUAY_API_TOKEN }}
51 changes: 41 additions & 10 deletions .github/workflows/step_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ on:
organization:
type: string
description: Organization
registry_provider:
type: string
description: Registry Provider
secrets:
login:
required: true
password:
required: true
quay_api_token:
required: true

jobs:
images:
Expand All @@ -24,15 +29,23 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Get target branch
id: target_branch
- name: Get step vars
id: vars
run: |
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
echo "name=$(echo ${GITHUB_REF##*/})" >> $GITHUB_OUTPUT
echo "branch_name=$(echo ${GITHUB_REF##*/})" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
echo "name=$(echo $GITHUB_BASE_REF)" >> $GITHUB_OUTPUT
echo "branch_name=$(echo $GITHUB_BASE_REF)" >> $GITHUB_OUTPUT
else
echo "name=nightly" >> $GITHUB_OUTPUT
echo "branch_name=nightly" >> $GITHUB_OUTPUT
fi
# Repo name for container registries
if [ ${{ inputs.registry_provider }} == 'dockerhub' ]; then
echo "repo_name=$(make docker-repo-name)" >> $GITHUB_OUTPUT
else
export DOCKER_REPO="$(echo quay.io/${GITHUB_REPOSITORY_OWNER} | tr -d '-')"
echo "repo_name=$(make docker-repo-name)" >> $GITHUB_OUTPUT
fi
- name: Download go build artifacts
Expand All @@ -48,23 +61,41 @@ jobs:
- name: Build container images
run: |
chmod +x -R .build
make docker DOCKER_IMAGE_TAG=${{ steps.target_branch.outputs.name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker DOCKER_IMAGE_TAG=${{ steps.vars.outputs.branch_name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
docker images
- name: Test container images
run: make test-docker DOCKER_IMAGE_TAG=${{ steps.target_branch.outputs.name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
run: make test-docker DOCKER_IMAGE_TAG=${{ steps.vars.outputs.branch_name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}

- name: Publish image for current branch/tag
if: github.ref == 'refs/heads/main'
run: |
echo ${{ secrets.password }} | docker login -u ${{ secrets.login }} --password-stdin ${{ inputs.registry }}
make docker-publish DOCKER_IMAGE_TAG=${{ steps.target_branch.outputs.name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-manifest DOCKER_IMAGE_TAG=${{ steps.target_branch.outputs.name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-publish DOCKER_IMAGE_TAG=${{ steps.vars.outputs.branch_name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-manifest DOCKER_IMAGE_TAG=${{ steps.vars.outputs.branch_name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
- name: Publish image with latest tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: |
echo ${{ secrets.password }} | docker login -u ${{ secrets.login }} --password-stdin ${{ inputs.registry }}
make docker-tag-latest DOCKER_IMAGE_TAG=${{ steps.target_branch.outputs.name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-tag-latest DOCKER_IMAGE_TAG=${{ steps.vars.outputs.branch_name }} DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-publish DOCKER_IMAGE_TAG=latest DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-manifest DOCKER_IMAGE_TAG=latest DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
- name: Push README to registry
uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1
if: github.ref == 'refs/heads/main' && github.repository_owner == 'mahendrapaipuri' # Don't run this workflow on forks.
# NOTE: We need to remove it once we trim down the README and move content to
# dedicated docs. DockerHub complains about too many characters in README
continue-on-error: true
env:
# For dockerhub registry
DOCKER_USER: ${{ secrets.login }}
DOCKER_PASS: ${{ secrets.password }}
# For quay.io
DOCKER_APIKEY: ${{ secrets.quay_api_token }}
with:
destination_container_repo: ${{ steps.vars.outputs.repo_name }}
provider: ${{ inputs.registry_provider }}
short_description: ${{ steps.vars.outputs.repo_name }}
readme_file: 'README.md'
4 changes: 4 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ common-tarball: promu
@echo ">> building release tarball"
$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)

.PHONY: common-docker-repo-name
common-docker-repo-name:
@echo "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)"

.PHONY: common-docker $(BUILD_DOCKER_ARCHS)
common-docker: $(BUILD_DOCKER_ARCHS)
$(BUILD_DOCKER_ARCHS): common-docker-%:
Expand Down

0 comments on commit 623e13a

Please sign in to comment.