Skip to content

Commit

Permalink
feat: set dockerhub description with build-docker-meta workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Oct 23, 2024
1 parent 0cbeebc commit 6ba9d8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-docker-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ jobs:
- name: Prepare build-time variables
id: vars
run: |
echo "CONTEXT=$(dirname ${{ github.event.inputs.dockerfile }})" >> "$GITHUB_OUTPUT"
echo "DATE=$(date +"%Y-%m-%d")" >> "$GITHUB_OUTPUT"
if [ ! -f ${{ github.event.inputs.dockerfile }} ] ; then
echo "ERROR: Dockerfile not found: ${{ github.event.inputs.dockerfile }}"
exit 1
fi
echo "CONTEXT=$(dirname ${{ github.event.inputs.dockerfile }})" >> "$GITHUB_OUTPUT"
echo "DATE=$(date +"%Y-%m-%d")" >> "$GITHUB_OUTPUT"
# for Docker Hub Description
echo " # ${{ github.repository }} ${{ github.event.inputs.image_name }}\n" > tmp_README.md
echo "Dockerfile source: https://github.com/${{ github.repository }}/blob/${{ github.sha }}/${{ github.event.inputs.dockerfile }}\n" >> tmp_README.md
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/build-docker-meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ jobs:
id: vars
run: |
echo "DATE=$(date +"%Y-%m-%d")" >> "$GITHUB_OUTPUT"
if [ ! -f ${{ github.event.inputs.context_dir }}/Dockerfile ] ; then
echo "ERROR: Dockerfile not found: ${{ github.event.inputs.context_dir }}/Dockerfile"
exit 1
fi
# for Docker Hub Description
echo " # ${{ github.repository }} ${{ steps.metadata.outputs['image_name'] }}\n" > tmp_README.md
echo "Dockerfile source: https://github.com/${{ github.repository }}/blob/${{ github.sha }}/${{ github.event.inputs.context_dir }}/Dockerfile\n" >> tmp_README.md
- name: Build and push
uses: docker/build-push-action@v4
# only try building & pushing the container if parsing the metadata worked
Expand All @@ -46,3 +54,11 @@ jobs:
BUILD_DATE=${{ steps.vars.outputs.DATE }}
BUILD_TAG=${{ steps.metadata.outputs['version'] }}
REPONAME=${{ steps.metadata.outputs['image_name'] }}
- name: Update Docker Hub Description
if: ${{ github.event.inputs.push == 'true' }}
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: peterevans/dockerhub-description
readme-filepath: tmp_README.md

0 comments on commit 6ba9d8f

Please sign in to comment.