Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7567c7b51b | ||
|
|
861e7a6d6a | ||
|
|
97941981d1 | ||
|
|
7041d8f35d | ||
|
|
843595a14f | ||
|
|
aa956b3fe8 | ||
|
|
e27c9c84cb | ||
|
|
26be7144b7 | ||
|
|
704c6b40c4 | ||
|
|
60c3aacb17 | ||
|
|
69ba977c50 | ||
|
|
a556e80cb3 | ||
|
|
96ab422aa6 | ||
|
|
09a017779e | ||
|
|
9baceaf7be | ||
|
|
30d779d1a8 | ||
|
|
8a5806631a |
@@ -1,70 +0,0 @@
|
||||
version: 2.1
|
||||
executors:
|
||||
docker-executor:
|
||||
environment:
|
||||
IMAGE_NAME: peterevans/dockerhub-description
|
||||
docker:
|
||||
- image: circleci/buildpack-deps:stretch
|
||||
jobs:
|
||||
build:
|
||||
executor: docker-executor
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker:
|
||||
docker_layer_caching: true
|
||||
- run:
|
||||
name: Build Docker image
|
||||
command: |
|
||||
docker build -t $IMAGE_NAME:latest . --label "org.opencontainers.image.version=${CIRCLE_TAG/v/''}"
|
||||
- run:
|
||||
name: Cache Docker image
|
||||
command: docker save -o image.tar $IMAGE_NAME
|
||||
- persist_to_workspace:
|
||||
root: .
|
||||
paths:
|
||||
- ./image.tar
|
||||
publish-tag:
|
||||
executor: docker-executor
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: /tmp/workspace
|
||||
- setup_remote_docker
|
||||
- run:
|
||||
name: Load cached Docker image
|
||||
command: docker load -i /tmp/workspace/image.tar
|
||||
- run:
|
||||
name: Publish Docker Image to Docker Hub
|
||||
command: |
|
||||
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
|
||||
IMAGE_TAG=${CIRCLE_TAG/v/''}
|
||||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG
|
||||
docker push $IMAGE_NAME:latest
|
||||
docker push $IMAGE_NAME:$IMAGE_TAG
|
||||
# If the minor version can be extracted then tag and push
|
||||
MINOR_VERSION=$(echo $CIRCLE_TAG | sed -n "s/^v\([0-9]*.[0-9]*\).[0-9]*$/\1/p")
|
||||
if [[ ${#MINOR_VERSION} -gt 0 ]]; then
|
||||
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$MINOR_VERSION
|
||||
docker push $IMAGE_NAME:$MINOR_VERSION
|
||||
fi
|
||||
workflows:
|
||||
version: 2
|
||||
build:
|
||||
jobs:
|
||||
- build
|
||||
build-and-publish-tags:
|
||||
jobs:
|
||||
- build:
|
||||
filters:
|
||||
tags:
|
||||
only: /^v.*/
|
||||
branches:
|
||||
ignore: /.*/
|
||||
- publish-tag:
|
||||
context: org-global
|
||||
requires:
|
||||
- build
|
||||
filters:
|
||||
tags:
|
||||
only: /^v.*/
|
||||
branches:
|
||||
ignore: /.*/
|
||||
15
.github/main.workflow
vendored
15
.github/main.workflow
vendored
@@ -1,15 +0,0 @@
|
||||
workflow "Update Docker Hub Description" {
|
||||
resolves = ["Docker Hub Description"]
|
||||
on = "push"
|
||||
}
|
||||
|
||||
action "Filter master branch" {
|
||||
uses = "actions/bin/filter@master"
|
||||
args = "branch master"
|
||||
}
|
||||
|
||||
action "Docker Hub Description" {
|
||||
needs = ["Filter master branch"]
|
||||
uses = "./"
|
||||
secrets = ["DOCKERHUB_USERNAME", "DOCKERHUB_PASSWORD", "DOCKERHUB_REPOSITORY"]
|
||||
}
|
||||
16
.github/workflows/push.yml
vendored
Normal file
16
.github/workflows/push.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Update Docker Hub Description
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
dockerHubDescription:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Docker Hub Description
|
||||
uses: ./
|
||||
env:
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description
|
||||
106
README.md
106
README.md
@@ -1,5 +1,6 @@
|
||||
# Docker Hub Description
|
||||
[](https://github.com/marketplace/actions/docker-hub-description)
|
||||
[](https://circleci.com/gh/peter-evans/dockerhub-description/tree/master)
|
||||
|
||||
A GitHub action to update a Docker Hub repository description from `README.md`.
|
||||
|
||||
@@ -7,68 +8,89 @@ This is useful if you `docker push` your images to Docker Hub. It provides an ea
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
action "Docker Hub Description" {
|
||||
uses = "peter-evans/dockerhub-description@v1.0.0"
|
||||
secrets = ["DOCKERHUB_USERNAME", "DOCKERHUB_PASSWORD", "DOCKERHUB_REPOSITORY"]
|
||||
}
|
||||
```yml
|
||||
- name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v2.0.0
|
||||
env:
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description
|
||||
```
|
||||
|
||||
#### Required secrets
|
||||
#### Required environment variables
|
||||
|
||||
- `DOCKERHUB_USERNAME` - Docker Hub username
|
||||
- `DOCKERHUB_PASSWORD` - Docker Hub password
|
||||
- `DOCKERHUB_REPOSITORY` - The name of the Docker Hub repository to update. The action combines this with the username to locate the repository. i.e. `username/repository`
|
||||
- `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.
|
||||
- `DOCKERHUB_REPOSITORY` - The Docker Hub repository to update in the format `<namespace>/<name>`.
|
||||
|
||||
Note that `DOCKERHUB_USERNAME` and `DOCKERHUB_REPOSITORY` may also be environment variables if not considered sensitive.
|
||||
Note that `DOCKERHUB_REPOSITORY` may also be passed as a secret if considered sensitive.
|
||||
|
||||
#### 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.
|
||||
|
||||
```
|
||||
action "Docker Hub Description" {
|
||||
uses = "peter-evans/dockerhub-description@v1.0.0"
|
||||
secrets = ["DOCKERHUB_USERNAME", "DOCKERHUB_PASSWORD", "DOCKERHUB_REPOSITORY"]
|
||||
env = {
|
||||
README_FILEPATH = "./some-path/README.md"
|
||||
}
|
||||
}
|
||||
```yml
|
||||
- name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v2.0.0
|
||||
env:
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description
|
||||
README_FILEPATH: ./some-path/README.md
|
||||
```
|
||||
|
||||
#### Examples
|
||||
|
||||
Updates the Docker Hub repository description whenever there is a `git push` to the `master` branch.
|
||||
```
|
||||
workflow "Update Docker Hub Description" {
|
||||
resolves = ["Docker Hub Description"]
|
||||
on = "push"
|
||||
}
|
||||
|
||||
action "Filter master branch" {
|
||||
uses = "actions/bin/filter@master"
|
||||
args = "branch master"
|
||||
}
|
||||
|
||||
action "Docker Hub Description" {
|
||||
needs = ["Filter master branch"]
|
||||
uses = "peter-evans/dockerhub-description@v1.0.0"
|
||||
secrets = ["DOCKERHUB_USERNAME", "DOCKERHUB_PASSWORD", "DOCKERHUB_REPOSITORY"]
|
||||
}
|
||||
```yml
|
||||
name: Update Docker Hub Description
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
dockerHubDescription:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v2.0.0
|
||||
env:
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description
|
||||
```
|
||||
|
||||
Updates the Docker Hub repository description whenever a new release is created.
|
||||
```yml
|
||||
name: Update Docker Hub Description
|
||||
on: release
|
||||
jobs:
|
||||
dockerHubDescription:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Docker Hub Description
|
||||
uses: peter-evans/dockerhub-description@v2.0.0
|
||||
env:
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description
|
||||
```
|
||||
workflow "Update Docker Hub Description" {
|
||||
resolves = ["Docker Hub Description"]
|
||||
on = "release"
|
||||
}
|
||||
|
||||
action "Docker Hub Description" {
|
||||
uses = "peter-evans/dockerhub-description@v1.0.0"
|
||||
secrets = ["DOCKERHUB_USERNAME", "DOCKERHUB_PASSWORD", "DOCKERHUB_REPOSITORY"]
|
||||
}
|
||||
## 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' \
|
||||
-e DOCKERHUB_REPOSITORY='user1/my-docker-image' \
|
||||
-e README_FILEPATH='/workspace/README.md' \
|
||||
peterevans/dockerhub-description:2.0.0
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
9
action.yml
Normal file
9
action.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
name: 'Docker Hub Description'
|
||||
author: 'Peter Evans'
|
||||
description: 'An action to update a Docker Hub repository description from README.md'
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'docker://peterevans/dockerhub-description:2.1.0'
|
||||
branding:
|
||||
icon: 'upload'
|
||||
color: 'blue'
|
||||
@@ -12,8 +12,8 @@ TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d ${LOGIN_PAYLOAD}
|
||||
|
||||
# Send a PATCH request to update the description of the repository
|
||||
echo "Sending PATCH request"
|
||||
REPO_URL="https://hub.docker.com/v2/repositories/${DOCKERHUB_USERNAME}/${DOCKERHUB_REPOSITORY}/"
|
||||
RESPONSE_CODE=$(curl -s --write-out %{response_code} --silent --output /dev/null -H "Authorization: JWT ${TOKEN}" -X PATCH --data-urlencode full_description@${README_FILEPATH} ${REPO_URL})
|
||||
REPO_URL="https://hub.docker.com/v2/repositories/${DOCKERHUB_REPOSITORY}/"
|
||||
RESPONSE_CODE=$(curl -s --write-out %{response_code} --output /dev/null -H "Authorization: JWT ${TOKEN}" -X PATCH --data-urlencode full_description@${README_FILEPATH} ${REPO_URL})
|
||||
echo "Received response code: $RESPONSE_CODE"
|
||||
|
||||
if [ $RESPONSE_CODE -eq 200 ]; then
|
||||
|
||||
Reference in New Issue
Block a user