2019-06-25 12:33:09 +02:00
# Docker Hub Description
2019-06-25 12:53:47 +02:00
[![GitHub Marketplace ](https://img.shields.io/badge/Marketplace-Docker%20Hub%20Description-blue.svg?colorA=24292e&colorB=0366d6&style=flat&longCache=true&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAM6wAADOsB5dZE0gAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAERSURBVCiRhZG/SsMxFEZPfsVJ61jbxaF0cRQRcRJ9hlYn30IHN/+9iquDCOIsblIrOjqKgy5aKoJQj4O3EEtbPwhJbr6Te28CmdSKeqzeqr0YbfVIrTBKakvtOl5dtTkK+v4HfA9PEyBFCY9AGVgCBLaBp1jPAyfAJ/AAdIEG0dNAiyP7+K1qIfMdonZic6+WJoBJvQlvuwDqcXadUuqPA1NKAlexbRTAIMvMOCjTbMwl1LtI/6KWJ5Q6rT6Ht1MA58AX8Apcqqt5r2qhrgAXQC3CZ6i1+KMd9TRu3MvA3aH/fFPnBodb6oe6HM8+lYHrGdRXW8M9bMZtPXUji69lmf5Cmamq7quNLFZXD9Rq7v0Bpc1o/tp0fisAAAAASUVORK5CYII= )](https://github.com/marketplace/actions/docker-hub-description)
2019-06-25 12:33:09 +02:00
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
2019-08-12 07:18:43 +02:00
```yml
- name: Docker Hub Description
2020-03-28 02:14:18 +01:00
uses: peter-evans/dockerhub-description@v2
2019-08-12 07:18:43 +02:00
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
2019-08-22 03:56:12 +02:00
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description
2019-06-25 12:33:09 +02:00
```
2019-08-22 03:56:12 +02:00
#### Required environment variables
2019-06-25 12:33:09 +02:00
2019-08-27 05:01:15 +02:00
- `DOCKERHUB_USERNAME` - Docker Hub username. If updating a Docker Hub repository belonging to an organization, this user must have `Admin` permissions for the repository.
- `DOCKERHUB_PASSWORD` - Docker Hub password.
2019-12-25 04:29:43 +01:00
- `DOCKERHUB_REPOSITORY` - The Docker Hub repository to update in the format `<namespace>/<name>` . May also be passed as a secret if considered sensitive.
2019-06-26 00:49:55 +02:00
2019-12-29 04:28:20 +01:00
**Note**: Docker Hub [Personal Access Tokens ](https://docs.docker.com/docker-hub/access-tokens/ ) cannot be used as they are not supported by the API. See [here ](https://github.com/docker/hub-feedback/issues/1927 ) and [here ](https://github.com/docker/hub-feedback/issues/1914 ) for further details. Unfortunately, this means that enabling the new 2FA feature on Docker Hub will prevent the action from working.
2019-06-25 12:33:09 +02:00
#### Optionally 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 overridden with an environment variable.
2019-08-12 07:18:43 +02:00
```yml
- name: Docker Hub Description
2020-03-28 02:14:18 +01:00
uses: peter-evans/dockerhub-description@v2
2019-08-12 07:18:43 +02:00
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
2019-08-22 03:56:12 +02:00
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description
2019-08-12 07:18:43 +02:00
README_FILEPATH: ./some-path/README.md
2019-06-25 12:33:09 +02:00
```
#### Examples
2019-11-10 13:59:08 +01:00
The following workflow updates the Docker Hub repository description whenever there are changes to `README.md` and the workflow file itself on the `master` branch. This workflow assumes its location to be `.github/workflows/dockerhub-description.yml` .
2019-08-12 07:18:43 +02:00
```yml
name: Update Docker Hub Description
2019-08-12 10:31:07 +02:00
on:
push:
branches:
2019-11-10 13:59:08 +01:00
- master
paths:
- README.md
- .github/workflows/dockerhub-description.yml
2019-08-12 07:18:43 +02:00
jobs:
dockerHubDescription:
runs-on: ubuntu-latest
steps:
2020-01-04 01:21:19 +01:00
- uses: actions/checkout@v2
2019-08-12 07:18:43 +02:00
- name: Docker Hub Description
2020-03-28 02:14:18 +01:00
uses: peter-evans/dockerhub-description@v2
2019-08-12 07:18:43 +02:00
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
2019-08-22 03:56:12 +02:00
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description
2019-06-25 12:33:09 +02:00
```
Updates the Docker Hub repository description whenever a new release is created.
2019-11-10 13:59:08 +01:00
2019-08-12 07:18:43 +02:00
```yml
name: Update Docker Hub Description
2019-08-12 10:31:07 +02:00
on: release
2019-08-12 07:18:43 +02:00
jobs:
dockerHubDescription:
runs-on: ubuntu-latest
steps:
2020-01-04 01:21:19 +01:00
- uses: actions/checkout@v2
2019-08-12 07:18:43 +02:00
- name: Docker Hub Description
2020-03-28 02:14:18 +01:00
uses: peter-evans/dockerhub-description@v2
2019-08-12 07:18:43 +02:00
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
2019-08-22 03:56:12 +02:00
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description
2019-06-25 12:33:09 +02:00
```
2019-06-30 04:17:55 +02:00
## 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.
```bash
docker run -v $PWD:/workspace \
-e DOCKERHUB_USERNAME='user1' \
-e DOCKERHUB_PASSWORD='xxxxx' \
2019-08-22 03:56:12 +02:00
-e DOCKERHUB_REPOSITORY='user1/my-docker-image' \
2019-06-30 04:17:55 +02:00
-e README_FILEPATH='/workspace/README.md' \
2020-03-28 02:14:18 +01:00
peterevans/dockerhub-description:2.1
2019-06-30 04:17:55 +02:00
```
2019-06-25 12:33:09 +02:00
## License
2019-11-10 13:59:08 +01:00
[MIT ](LICENSE )