Skip to content

Commit

Permalink
Add DockerHub description upon deployment
Browse files Browse the repository at this point in the history
When docker images have been successfully deployed and tested, update the
DockerHub description with the current version of the README.md from github.
This is similar to what DockerHub Autobuild does, if it were used.
  • Loading branch information
ArturKlauser authored and mvdan committed Jan 30, 2020
1 parent 3059814 commit 9834d31
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ jobs:
env:
# Export environment variables for all stages.
DOCKER_CLI_EXPERIMENTAL: enabled # for 'docker buildx'
DOCKER_BASE: mvdan/shfmt
DOCKER_USER: mvdan
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
DOCKER_REPO: shfmt
# We use all platforms for which FROM images in our Dockerfile are
# available.
DOCKER_PLATFORMS: >
Expand All @@ -95,6 +96,7 @@ jobs:
# Pushes tag - deploy tag name.
echo "::set-env name=TAG::${GITHUB_REF/refs\/tags\//}"
fi
echo "::set-env name=DOCKER_BASE::${DOCKER_USER}/${DOCKER_REPO}"
- name: Install Docker buildx
run: |
set -vx
Expand Down Expand Up @@ -126,8 +128,8 @@ jobs:
- name: Build multi-architecture Docker images with buildx
run: |
set -vx
username=${DOCKER_BASE/\/*/}
echo "$DOCKER_PASSWORD" | docker login -u="$username" --password-stdin
echo "$DOCKER_PASSWORD" \
| docker login -u="$DOCKER_USER" --password-stdin
function buildx() {
docker buildx build \
Expand Down Expand Up @@ -164,3 +166,30 @@ jobs:
docker run --rm -v "$PWD:/mnt" -w '/mnt' "$image" -d myscript
done
done
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 13.x
- name: Update DockerHub description
run: |
set -vx
npm install [email protected]
node -e '
const fs = require("fs");
let readme = fs.readFileSync("README.md", "utf8");
let dockerHubAPI = require("docker-hub-api");
dockerHubAPI.login(
process.env.DOCKER_USER,
process.env.DOCKER_PASSWORD)
.then(function () {
let url = "https://github.com/" + process.env.GITHUB_REPOSITORY;
for (let ext of ["-alpine", ""]) {
let repo = process.env.DOCKER_REPO + ext;
dockerHubAPI.setRepositoryDescription(
process.env.DOCKER_USER,
repo,
{short: "Official " + repo + " images from " + url,
full: readme});
}
});
'

0 comments on commit 9834d31

Please sign in to comment.