Skip to content

Commit b59de63

Browse files
committed
Automatically update descriptions on Docker Hub
1 parent 733f258 commit b59de63

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Update Docker Hub Description
2+
on:
3+
push:
4+
branches:
5+
- main
6+
# REMOVE BEFORE FLIGHT: for testing
7+
- dockerhub-descriptions
8+
# paths:
9+
# - versions.md
10+
# - README.md
11+
# - docs/**/*
12+
13+
workflow_dispatch:
14+
15+
jobs:
16+
updateDescriptions:
17+
name: Update description
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
image:
22+
- minimal
23+
- core
24+
- latex
25+
- extra
26+
- typst
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Setup pandoc
33+
uses: pandoc/actions/setup@v1
34+
35+
- name: Short description
36+
id: config
37+
run: |
38+
printf 'short_description=%s\n' \
39+
"$(pandoc lua docs/scripts/short-description.lua \
40+
${{ matrix.image }})" \
41+
>> $GITHUB_OUTPUT
42+
43+
44+
- name: Generate README files
45+
run: |
46+
make docs-${{ matrix.image }} > /tmp/README.${{ matrix.image }}.md
47+
48+
- name: Update ${{ matrix.image }}
49+
uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae
50+
with:
51+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
52+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
53+
repository: pandoc/${{ matrix.image }}
54+
readme-filepath: /tmp/README.${{ matrix.image }}.md
55+
short-description: ${{ steps.config.outputs.short_description }}

docs/scripts/short-description.lua

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--- short-description.lua: get the short description for a repository
2+
--- Author: Albert Krewinkel <[email protected]>
3+
--- License: MIT
4+
5+
local io = require 'io'
6+
local pandoc = require 'pandoc'
7+
8+
local stringify = pandoc.utils.stringify
9+
10+
--- Command-line arguments
11+
local arg = arg
12+
13+
--- The image type / repository name
14+
local repo = assert(arg[1], "Repository name is required")
15+
local inputfile = arg[2] or 'docs/short-descriptions.md'
16+
local fh = io.open(inputfile, 'r')
17+
local contents = fh:read('a')
18+
fh:close()
19+
20+
local doc = pandoc.read(contents)
21+
22+
assert(doc.meta[repo], "No description found for repository " .. repo)
23+
24+
print(stringify(doc.meta[repo]))

0 commit comments

Comments
 (0)