A GitHub action to update a Docker Hub repository description from README.md https://github.com/peter-evans/dockerhub-description.git
Find a file
dependabot[bot] 7f3fdb8ae5
build(deps-dev): bump @types/node from 16.18.101 to 16.18.103 (#273)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 16.18.101 to 16.18.103.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-21 14:45:18 +00:00
.github build(deps): bump peter-evans/create-pull-request from 5 to 6 (#249) 2024-02-04 14:06:47 +00:00
__test__ feat: truncate short description exceeding the byte limit (#143) 2023-04-07 09:16:46 +09:00
dist build: update distribution (#211) 2023-09-18 17:14:06 +09:00
src fix: use the truncated short description (#148) 2023-04-10 08:18:10 +09:00
.eslintignore refactor: convert to typescript 2020-09-23 15:58:54 +09:00
.eslintrc.json fix: remove unnecessary prettier config 2021-03-16 12:43:43 +09:00
.gitignore refactor: convert to typescript 2020-09-23 15:58:54 +09:00
.prettierignore refactor: convert to typescript 2020-09-23 15:58:54 +09:00
.prettierrc.json refactor: convert to typescript 2020-09-23 15:58:54 +09:00
action.yml feat: update runtime to node 20 (#246) 2024-01-25 21:25:01 +09:00
Dockerfile refactor: update image to execute action with node 2020-09-23 17:23:10 +09:00
entrypoint.sh fix: Use absolute path to index.js in entrypoint (#176) 2023-06-20 16:32:15 +09:00
jest.config.js feat: convert relative urls to absolute (#125) (#126) 2023-03-05 11:13:27 +09:00
LICENSE Initial commit 2019-06-25 19:19:47 +09:00
package-lock.json build(deps-dev): bump @types/node from 16.18.101 to 16.18.103 (#273) 2024-07-21 14:45:18 +00:00
package.json build(deps-dev): bump @types/node from 16.18.101 to 16.18.103 (#273) 2024-07-21 14:45:18 +00:00
README.md feat: update runtime to node 20 (#246) 2024-01-25 21:25:01 +09:00
tsconfig.json refactor: convert to typescript 2020-09-23 15:58:54 +09:00

Docker Hub Description

GitHub Marketplace

A GitHub action to update a Docker Hub repository description from README.md.

This is useful if you docker push your images to Docker Hub. It provides an easy, automated way to keep your Docker Hub repository description in sync with your GitHub repository README.md file.

Usage

    - uses: actions/checkout@v4

    - name: Docker Hub Description
      uses: peter-evans/dockerhub-description@v4
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_PASSWORD }}
        repository: peterevans/dockerhub-description

Action inputs

Name Description Default
username (required) Docker Hub username. If updating a Docker Hub repository belonging to an organization, this user must have Admin permissions for the repository.
password (required) Docker Hub password or Personal Access Token with read/write/delete scope.
repository Docker Hub repository in the format <namespace>/<name>. github.repository
short-description Docker Hub repository short description.
readme-filepath Path to the repository readme. ./README.md
enable-url-completion Enables completion of relative URLs to absolute ones. See also known Issues. false
image-extensions File extensions that will be treated as images. bmp,gif,jpg,jpeg,png,svg,webp

Content limits

DockerHub has content limits. The readme content is limited to 25,000 bytes, and short-description is limited to 100 bytes. This action truncates content to prevent the request being rejected. If the content has been truncated a warning will be issued in the run log.

Specifying the file path

The action assumes that there is a file called README.md located at the root of the repository. If this is not the case the path can be specified with the readme-filepath input.

    - name: Docker Hub Description
      uses: peter-evans/dockerhub-description@v4
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_PASSWORD }}
        repository: peterevans/dockerhub-description
        readme-filepath: ./path/to/README.md

Using the GitHub repository description

The GitHub repository description can be used for the Docker Hub short-descripton by passing the description from the event context.

    - name: Docker Hub Description
      uses: peter-evans/dockerhub-description@v4
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_PASSWORD }}
        repository: peterevans/dockerhub-description
        short-description: ${{ github.event.repository.description }}

Examples

The following workflow updates the Docker Hub repository description whenever there are changes to README.md and the workflow file itself on the main branch. This workflow assumes its location to be .github/workflows/dockerhub-description.yml.

name: Update Docker Hub Description
on:
  push:
    branches:
      - main
    paths:
      - README.md
      - .github/workflows/dockerhub-description.yml
jobs:
  dockerHubDescription:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Docker Hub Description
      uses: peter-evans/dockerhub-description@v4
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_PASSWORD }}
        repository: peterevans/dockerhub-description
        short-description: ${{ github.event.repository.description }}
        enable-url-completion: true

Updates the Docker Hub repository description whenever a new release is created.

name: Update Docker Hub Description
on: release
jobs:
  dockerHubDescription:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Docker Hub Description
      uses: peter-evans/dockerhub-description@v4
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_PASSWORD }}
        repository: peterevans/dockerhub-description
        short-description: ${{ github.event.repository.description }}

URL completion known Issues

The completion of relative URLs has some known issues:

  1. Relative markdown links in inline-code and code blocks are also converted:

    [link in inline code](#table-of-content)
    

    will be converted into

    [link in inline code](https://github.com/peter-evans/dockerhub-description/blob/main/./README.md#table-of-content)
    
  2. Links containing square brackets (]) in the text fragment are not converted:

    [[link text with square brackets]](#table-of-content)
    
  3. Reference-style links/images are not converted.

    [table-of-content][toc]
    
    ...
    
    [toc]: #table-of-content "Table of content"
    

Using the Docker image independently of GitHub Actions

The image can be executed in other environments independently of GitHub Actions. Simply volume mount the location of the README.md file to the container and set environment variables as follows.

docker run -v $PWD:/workspace \
  -e DOCKERHUB_USERNAME='user1' \
  -e DOCKERHUB_PASSWORD='xxxxx' \
  -e DOCKERHUB_REPOSITORY='user1/my-docker-image' \
  -e README_FILEPATH='/workspace/README.md' \
  peterevans/dockerhub-description:3

License

MIT