17 Commits

Author SHA1 Message Date
Peter Evans
2739a0900f Update action version 2020-03-28 10:05:06 +09:00
Peter Evans
84d38211e2 Check if file size exceeds the max allowed 2020-03-28 09:52:49 +09:00
Peter Evans
abea83050d Update to checkout v2 2020-01-04 09:21:19 +09:00
Peter Evans
3361358488 Update README 2019-12-29 12:28:20 +09:00
Peter Evans
2774ff3d56 Update README 2019-12-25 12:29:43 +09:00
Peter Evans
b03d823861 Update README 2019-11-10 21:59:08 +09:00
Peter Evans
6de5e14b55 Update workflow 2019-11-10 21:57:41 +09:00
Peter Evans
5b8fd77939 Update workflow 2019-10-29 00:52:05 +09:00
Peter Evans
81f3992e82 Update workflow 2019-10-29 00:50:55 +09:00
Peter Evans
5e7108e09c Update README 2019-10-03 16:52:08 +09:00
Peter Evans
f87713fbd6 Update README 2019-10-03 16:51:29 +09:00
Peter Evans
7567c7b51b Merge pull request #4 from peter-evans/container-action-update
Update for Actions v2
2019-10-03 16:46:09 +09:00
Peter Evans
861e7a6d6a Remove circleci config 2019-10-03 16:39:54 +09:00
Peter Evans
97941981d1 Update workflow 2019-10-03 16:38:36 +09:00
Peter Evans
7041d8f35d Add action.yml for Actions v2 2019-10-03 16:33:09 +09:00
Peter Evans
843595a14f Update README 2019-08-27 12:01:15 +09:00
Peter Evans
aa956b3fe8 Update README 2019-08-22 11:02:17 +09:00
6 changed files with 58 additions and 101 deletions

View File

@@ -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: /.*/

View File

@@ -0,0 +1,24 @@
name: Update Docker Hub Description
on:
push:
branches:
- master
paths:
- README.md
- .github/workflows/dockerhub-description.yml
jobs:
dockerHubDescription:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Copy README.md to TEST.md
run: |
mkdir -p some/path
mv README.md some/path/TEST.md
- name: Docker Hub Description
uses: ./
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description
README_FILEPATH: ./some/path/TEST.md

View File

@@ -1,16 +0,0 @@
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: ./
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_REPOSITORY: peterevans/dockerhub-description

View File

@@ -1,6 +1,5 @@
# Docker Hub Description
[![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)
[![CircleCI](https://circleci.com/gh/peter-evans/dockerhub-description/tree/master.svg?style=svg)](https://circleci.com/gh/peter-evans/dockerhub-description/tree/master)
A GitHub action to update a Docker Hub repository description from `README.md`.
@@ -10,7 +9,7 @@ This is useful if you `docker push` your images to Docker Hub. It provides an ea
```yml
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v1.0.1
uses: peter-evans/dockerhub-description@v2.1.0
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -19,11 +18,11 @@ This is useful if you `docker push` your images to Docker Hub. It provides an ea
#### Required environment variables
- `DOCKERHUB_USERNAME` - Docker Hub username
- `DOCKERHUB_PASSWORD` - Docker Hub password
- `DOCKERHUB_REPOSITORY` - The Docker Hub repository to update in the format `<namespace>/<name>`
- `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>`. May also be passed as a secret if considered sensitive.
Note that `DOCKERHUB_REPOSITORY` may also be passed as a secret if considered sensitive.
**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.
#### Optionally specifying the file path
@@ -32,7 +31,7 @@ If this is not the case, the path can be overridden with an environment variable
```yml
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v1.0.1
uses: peter-evans/dockerhub-description@v2.1.0
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -42,20 +41,24 @@ If this is not the case, the path can be overridden with an environment variable
#### Examples
Updates the Docker Hub repository description whenever there is a `git push` to the `master` branch.
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`.
```yml
name: Update Docker Hub Description
on:
push:
branches:
- master
- master
paths:
- README.md
- .github/workflows/dockerhub-description.yml
jobs:
dockerHubDescription:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v1.0.1
uses: peter-evans/dockerhub-description@v2.1.0
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -63,6 +66,7 @@ jobs:
```
Updates the Docker Hub repository description whenever a new release is created.
```yml
name: Update Docker Hub Description
on: release
@@ -70,9 +74,9 @@ jobs:
dockerHubDescription:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v1.0.1
uses: peter-evans/dockerhub-description@v2.1.0
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -90,9 +94,9 @@ docker run -v $PWD:/workspace \
-e DOCKERHUB_PASSWORD='xxxxx' \
-e DOCKERHUB_REPOSITORY='user1/my-docker-image' \
-e README_FILEPATH='/workspace/README.md' \
peterevans/dockerhub-description:1.0.1
peterevans/dockerhub-description:2.1.0
```
## License
MIT License - see the [LICENSE](LICENSE) file for details
[MIT](LICENSE)

9
action.yml Normal file
View 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.1'
branding:
icon: 'upload'
color: 'blue'

View File

@@ -5,6 +5,12 @@ IFS=$'\n\t'
# Set the default path to README.md
README_FILEPATH=${README_FILEPATH:="./README.md"}
# Check the file size
if [ $(wc -c <${README_FILEPATH}) -gt 25000 ]; then
echo "File size exceeds the maximum allowed 25000 bytes"
exit 1
fi
# Acquire a token for the Docker Hub API
echo "Acquiring token"
LOGIN_PAYLOAD="{\"username\": \"${DOCKERHUB_USERNAME}\", \"password\": \"${DOCKERHUB_PASSWORD}\"}"