Compare commits
264 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0505d8b048 | ||
|
|
d40710dfb0 | ||
|
|
e12dc49964 | ||
|
|
83ee4db50f | ||
|
|
1f8ca783c6 | ||
|
|
c2fad95840 | ||
|
|
e4f42071e1 | ||
|
|
2a4d0d8597 | ||
|
|
8c1566cea4 | ||
|
|
7865ba66d0 | ||
|
|
617019887c | ||
|
|
36c4322b9c | ||
|
|
2d4672fae3 | ||
|
|
6c8e595086 | ||
|
|
d5aaec56d3 | ||
|
|
344a0f5a61 | ||
|
|
de1c042b3e | ||
|
|
e998ab2b91 | ||
|
|
c4521e2ba1 | ||
|
|
8810bfe821 | ||
|
|
d2101ede00 | ||
|
|
dd4be4fe43 | ||
|
|
588a4dbc86 | ||
|
|
0ab59cadf3 | ||
|
|
2896fee772 | ||
|
|
9b0b0341f4 | ||
|
|
9a7f6da6c6 | ||
|
|
d00dc51d35 | ||
|
|
076d82d008 | ||
|
|
e99e0aadc5 | ||
|
|
91421ce5e5 | ||
|
|
6ac6558a86 | ||
|
|
7f3fdb8ae5 | ||
|
|
848a6b3658 | ||
|
|
42a84a32e0 | ||
|
|
61c023b7e2 | ||
|
|
797bf6772a | ||
|
|
86c4b6183f | ||
|
|
7ecdbf1ebd | ||
|
|
cfcc4d556c | ||
|
|
ab28054a1a | ||
|
|
897de4afce | ||
|
|
18aad17c1c | ||
|
|
c2c3ecda63 | ||
|
|
b0ec9c8f31 | ||
|
|
f282736533 | ||
|
|
dba14ea5da | ||
|
|
dc5e7cc6f8 | ||
|
|
863f09a85d | ||
|
|
717038e89d | ||
|
|
771436f156 | ||
|
|
bb57852aa8 | ||
|
|
70d042f0d9 | ||
|
|
5abe9c24c3 | ||
|
|
fe5149b77e | ||
|
|
dfca62cfbb | ||
|
|
af41a4d8c7 | ||
|
|
ccd64af815 | ||
|
|
e98e4d1628 | ||
|
|
487b4536f5 | ||
|
|
f4367f9cb8 | ||
|
|
48ae68f5cc | ||
|
|
dfc61b859a | ||
|
|
74967fba19 | ||
|
|
7ea9d275c7 | ||
|
|
7bc76ab4eb | ||
|
|
5a219e72c3 | ||
|
|
fb37f44de8 | ||
|
|
090662666b | ||
|
|
7d9d33d1ad | ||
|
|
ede0e66c26 | ||
|
|
2eb6c2156a | ||
|
|
d749f34910 | ||
|
|
cbbf63cd44 | ||
|
|
c493b0c24f | ||
|
|
aef47f645f | ||
|
|
17e01bee3e | ||
|
|
5862ccd54c | ||
|
|
2d9834711c | ||
|
|
da6824c6fa | ||
|
|
447f37b1fb | ||
|
|
c3746eb94a | ||
|
|
3ed1138da6 | ||
|
|
12031e44df | ||
|
|
c14f7ff9e9 | ||
|
|
057ee23e8c | ||
|
|
312671fa99 | ||
|
|
8f8b8c99b1 | ||
|
|
5ad1124f4f | ||
|
|
9453e52a44 | ||
|
|
a99d66e8ec | ||
|
|
5c90d1ad12 | ||
|
|
dcf0a8fff6 | ||
|
|
73a580a1ae | ||
|
|
b1e39fd19f | ||
|
|
39bf3f4c11 | ||
|
|
62ba2ea0d3 | ||
|
|
3861b4b5c8 | ||
|
|
fbf02e87a8 | ||
|
|
ae2ba76d87 | ||
|
|
66dd6ac11f | ||
|
|
ce7ff9a828 | ||
|
|
15a517c06a | ||
|
|
7e13e37804 | ||
|
|
28ce628a86 | ||
|
|
52be71e834 | ||
|
|
85196c34e2 | ||
|
|
a7d6e3d9c6 | ||
|
|
c8ed26e537 | ||
|
|
6515ba32ab | ||
|
|
fd35f43fb8 | ||
|
|
6b24b4e0ae | ||
|
|
1156718ef8 | ||
|
|
14b47e3ff1 | ||
|
|
c3e7977d85 | ||
|
|
e02df362e0 | ||
|
|
3812f14543 | ||
|
|
2c2024be8b | ||
|
|
de56f90828 | ||
|
|
05b1c514cd | ||
|
|
1f52e08716 | ||
|
|
b8a53936ac | ||
|
|
a39ad46df2 | ||
|
|
dc67fad700 | ||
|
|
67a28beebc | ||
|
|
ab07c6ee52 | ||
|
|
1ebaf7335e | ||
|
|
b85449155b | ||
|
|
950d5c5a19 | ||
|
|
4f5c0cdd7c | ||
|
|
d790b19dfe | ||
|
|
8e5fadaee0 | ||
|
|
1590065a78 | ||
|
|
2e1b37d8fb | ||
|
|
3dc747dce1 | ||
|
|
2573e7f4c0 | ||
|
|
5059fd86e9 | ||
|
|
4ebf07e899 | ||
|
|
d722849477 | ||
|
|
d7ee0471b0 | ||
|
|
40314b1002 | ||
|
|
b95ff7bca1 | ||
|
|
9f9136cb72 | ||
|
|
16530875f9 | ||
|
|
955386a494 | ||
|
|
de77530ea5 | ||
|
|
2d1351cb35 | ||
|
|
11da833829 | ||
|
|
823190d895 | ||
|
|
1b71c03ec0 | ||
|
|
579f64ca0a | ||
|
|
3f29bdade4 | ||
|
|
8b56ea036f | ||
|
|
2e2fadf6e3 | ||
|
|
015b1b5f51 | ||
|
|
4b1a4bb484 | ||
|
|
3ba533f0ff | ||
|
|
f866d47eb4 | ||
|
|
03ca5ee9b4 | ||
|
|
a57cec0ff6 | ||
|
|
2a3abf56ec | ||
|
|
9e64bda1bc | ||
|
|
dd732b0272 | ||
|
|
24d9720e95 | ||
|
|
74d5634479 | ||
|
|
f92370924c | ||
|
|
32a61cce5a | ||
|
|
4a4792c2ca | ||
|
|
202973a37c | ||
|
|
728b36f7bb | ||
|
|
3f60feb215 | ||
|
|
812a4d0496 | ||
|
|
79b63455c0 | ||
|
|
e139363f61 | ||
|
|
bbef094b30 | ||
|
|
21ccfa72b4 | ||
|
|
067627a8af | ||
|
|
d514e8a638 | ||
|
|
d440d6b705 | ||
|
|
ebb09a6e43 | ||
|
|
842061843e | ||
|
|
b360ab3b73 | ||
|
|
7ca13a4f6e | ||
|
|
d244f2b158 | ||
|
|
2c16b08205 | ||
|
|
ebbe765cd1 | ||
|
|
20a27e1287 | ||
|
|
ffe399573c | ||
|
|
692ca5d836 | ||
|
|
d560591414 | ||
|
|
4b6b64d89b | ||
|
|
4e40b120de | ||
|
|
fcaa3f84b7 | ||
|
|
651109f8e8 | ||
|
|
b02c8b39c6 | ||
|
|
f0e52ee452 | ||
|
|
f8648cb2f7 | ||
|
|
81ec7f185c | ||
|
|
723ac59666 | ||
|
|
841dc674ea | ||
|
|
bc803ce02a | ||
|
|
e35d4507cd | ||
|
|
c3668578c8 | ||
|
|
dec2815534 | ||
|
|
f2b6dec597 | ||
|
|
22519658ca | ||
|
|
3901fb41b0 | ||
|
|
2956947109 | ||
|
|
4a7ad32d0a | ||
|
|
1c79b7b870 | ||
|
|
f1bd7c2b9a | ||
|
|
bcd6cafa5b | ||
|
|
a2a89a04dc | ||
|
|
a9d3672166 | ||
|
|
3bafe822d0 | ||
|
|
fd3ace2386 | ||
|
|
c5d7e00b1e | ||
|
|
93b93397c2 | ||
|
|
3103d1465d | ||
|
|
0b9f9c4786 | ||
|
|
3b9f4f25f0 | ||
|
|
1488116043 | ||
|
|
4fd465609e | ||
|
|
9404f28f56 | ||
|
|
eef18f85b1 | ||
|
|
db792ed6c9 | ||
|
|
4fdf852815 | ||
|
|
bc97286b92 | ||
|
|
b2ff61bdb1 | ||
|
|
c908a72eaf | ||
|
|
2c9ccb12d6 | ||
|
|
27a09e0234 | ||
|
|
da890086d3 | ||
|
|
afa309ec72 | ||
|
|
22ceabb390 | ||
|
|
5edfa5bd9e | ||
|
|
1cf9afbac3 | ||
|
|
8a5577cb53 | ||
|
|
836d7e6aa8 | ||
|
|
6c2330d495 | ||
|
|
7e2c013575 | ||
|
|
451dfdc2a0 | ||
|
|
72b5f8eb8c | ||
|
|
142e236b5b | ||
|
|
89908cabb5 | ||
|
|
d8b35356f3 | ||
|
|
b73baad189 | ||
|
|
2f090b7665 | ||
|
|
05c1ee4f23 | ||
|
|
051fe81a00 | ||
|
|
71d921164d | ||
|
|
675b619ca6 | ||
|
|
ff044ee025 | ||
|
|
2ad1a4749f | ||
|
|
b9a0540444 | ||
|
|
ec57f928ad | ||
|
|
86903dfeb9 | ||
|
|
ebf083452f | ||
|
|
0940284a04 | ||
|
|
27aaeae4e5 | ||
|
|
c827149363 | ||
|
|
0151f40476 | ||
|
|
31c84f79aa | ||
|
|
d43a08dfeb |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
github: peter-evans
|
||||||
21
.github/dependabot.yml
vendored
Normal file
21
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
day: "sunday"
|
||||||
|
labels:
|
||||||
|
- "dependencies"
|
||||||
|
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
day: "sunday"
|
||||||
|
ignore:
|
||||||
|
- dependency-name: "*"
|
||||||
|
update-types: ["version-update:semver-major"]
|
||||||
|
labels:
|
||||||
|
- "dependencies"
|
||||||
|
|
||||||
13
.github/workflows/automerge-dependabot.yml
vendored
Normal file
13
.github/workflows/automerge-dependabot.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
name: Auto-merge Dependabot
|
||||||
|
on: pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
automerge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.actor == 'dependabot[bot]'
|
||||||
|
steps:
|
||||||
|
- uses: peter-evans/enable-pull-request-automerge@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
||||||
|
pull-request-number: ${{ github.event.pull_request.number }}
|
||||||
|
merge-method: squash
|
||||||
29
.github/workflows/ci.yml
vendored
29
.github/workflows/ci.yml
vendored
@@ -10,24 +10,30 @@ on:
|
|||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'README.md'
|
- 'README.md'
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 20.x
|
||||||
|
cache: npm
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run format-check
|
- run: npm run format-check
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
- run: npm run test
|
- run: npm run test
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: action.yml
|
name: action.yml
|
||||||
path: action.yml
|
path: action.yml
|
||||||
@@ -40,14 +46,14 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
target: [built, committed]
|
target: [built, committed]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: action.yml
|
name: action.yml
|
||||||
path: .
|
path: .
|
||||||
@@ -80,14 +86,15 @@ jobs:
|
|||||||
needs: [test]
|
needs: [test]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v3
|
uses: peter-evans/create-pull-request@v7
|
||||||
with:
|
with:
|
||||||
|
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
||||||
commit-message: 'build: update distribution'
|
commit-message: 'build: update distribution'
|
||||||
title: Update distribution
|
title: Update distribution
|
||||||
body: |
|
body: |
|
||||||
|
|||||||
2
.github/workflows/dockerhub-description.yml
vendored
2
.github/workflows/dockerhub-description.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
dockerHubDescription:
|
dockerHubDescription:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Modify readme for DockerHub
|
- name: Modify readme for DockerHub
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
4
.github/workflows/publish-docker.yml
vendored
4
.github/workflows/publish-docker.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Docker Hub login
|
- name: Docker Hub login
|
||||||
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
|
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
|
||||||
@@ -38,4 +38,4 @@ jobs:
|
|||||||
MAJOR_VERSION=$(echo $VERSION | sed -n "s/^\([0-9]*\).[0-9]*.[0-9]*$/\1/p")
|
MAJOR_VERSION=$(echo $VERSION | sed -n "s/^\([0-9]*\).[0-9]*.[0-9]*$/\1/p")
|
||||||
[[ ${#MAJOR_VERSION} -gt 0 ]] && docker tag $IMAGE_NAME $IMAGE_NAME:$MAJOR_VERSION
|
[[ ${#MAJOR_VERSION} -gt 0 ]] && docker tag $IMAGE_NAME $IMAGE_NAME:$MAJOR_VERSION
|
||||||
|
|
||||||
docker push $IMAGE_NAME
|
docker push $IMAGE_NAME --all-tags
|
||||||
|
|||||||
31
.github/workflows/update-dep.yml
vendored
31
.github/workflows/update-dep.yml
vendored
@@ -1,31 +0,0 @@
|
|||||||
name: Update Dependencies
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 1 * * 4'
|
|
||||||
jobs:
|
|
||||||
update-dep:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: '12.x'
|
|
||||||
- name: Update dependencies
|
|
||||||
run: |
|
|
||||||
npx -p npm-check-updates ncu -u
|
|
||||||
npm install
|
|
||||||
- name: Create Pull Request
|
|
||||||
uses: peter-evans/create-pull-request@v3
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
|
||||||
commit-message: 'chore: update dependencies'
|
|
||||||
committer: GitHub <noreply@github.com>
|
|
||||||
author: actions-bot <actions-bot@users.noreply.github.com>
|
|
||||||
title: Update dependencies
|
|
||||||
body: |
|
|
||||||
- Dependency updates
|
|
||||||
|
|
||||||
Auto-generated by [create-pull-request][1]
|
|
||||||
|
|
||||||
[1]: https://github.com/peter-evans/create-pull-request
|
|
||||||
branch: update-dependencies
|
|
||||||
31
.github/workflows/update-major-version.yml
vendored
Normal file
31
.github/workflows/update-major-version.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
name: Update Major Version
|
||||||
|
run-name: Update ${{ github.event.inputs.main_version }} to ${{ github.event.inputs.target }}
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
target:
|
||||||
|
description: The target tag or reference
|
||||||
|
required: true
|
||||||
|
main_version:
|
||||||
|
type: choice
|
||||||
|
description: The major version tag to update
|
||||||
|
options:
|
||||||
|
- v4
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tag:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Git config
|
||||||
|
run: |
|
||||||
|
git config user.name actions-bot
|
||||||
|
git config user.email actions-bot@users.noreply.github.com
|
||||||
|
- name: Tag new target
|
||||||
|
run: git tag -f ${{ github.event.inputs.main_version }} ${{ github.event.inputs.target }}
|
||||||
|
- name: Push new tag
|
||||||
|
run: git push origin ${{ github.event.inputs.main_version }} --force
|
||||||
66
README.md
66
README.md
@@ -8,8 +8,10 @@ This is useful if you `docker push` your images to Docker Hub. It provides an ea
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Docker Hub Description
|
- name: Docker Hub Description
|
||||||
uses: peter-evans/dockerhub-description@v2
|
uses: peter-evans/dockerhub-description@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
@@ -18,15 +20,22 @@ This is useful if you `docker push` your images to Docker Hub. It provides an ea
|
|||||||
|
|
||||||
### Action inputs
|
### Action inputs
|
||||||
|
|
||||||
**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 2FA on Docker Hub will prevent the action from working.
|
|
||||||
|
|
||||||
| Name | Description | Default |
|
| Name | Description | Default |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `username` | (**required**) Docker Hub username. If updating a Docker Hub repository belonging to an organization, this user must have `Admin` permissions for the repository. | |
|
| `username` | (**required**) Docker Hub username. If updating a Docker Hub repository belonging to an organization, this user must have `Admin` permissions for the repository. | |
|
||||||
| `password` | (**required**) Docker Hub password. | |
|
| `password` | (**required**) Docker Hub password or [Personal Access Token](https://docs.docker.com/docker-hub/access-tokens/) with `read/write/delete` scope. | |
|
||||||
| `repository` | Docker Hub repository in the format `<namespace>/<name>`. | `github.repository` |
|
| `repository` | Docker Hub repository in the format `<namespace>/<name>`. | `github.repository` |
|
||||||
| `short-description` | Docker Hub repository short description. Input exceeding 100 characters will be truncated. | |
|
| `short-description` | Docker Hub repository short description. | |
|
||||||
| `readme-filepath` | Path to the repository readme. | `./README.md` |
|
| `readme-filepath` | Path to the repository readme. | `./README.md` |
|
||||||
|
| `enable-url-completion` | Enables completion of relative URLs to absolute ones. See also [known Issues](#url-completion-known-issues). | `false` |
|
||||||
|
| `image-extensions` | File extensions that will be treated as images. | `bmp,gif,jpg,jpeg,png,svg,webp` |
|
||||||
|
|
||||||
|
#### Content limits
|
||||||
|
|
||||||
|
DockerHub has content limits.
|
||||||
|
The readme content is limited to 25,000 bytes, and `short-description` is limited to 100 bytes.
|
||||||
|
This action truncates content to prevent the request being rejected.
|
||||||
|
If the content has been truncated a warning will be issued in the run log.
|
||||||
|
|
||||||
#### Specifying the file path
|
#### Specifying the file path
|
||||||
|
|
||||||
@@ -35,7 +44,7 @@ If this is not the case the path can be specified with the `readme-filepath` inp
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
- name: Docker Hub Description
|
- name: Docker Hub Description
|
||||||
uses: peter-evans/dockerhub-description@v2
|
uses: peter-evans/dockerhub-description@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
@@ -49,7 +58,7 @@ The GitHub repository description can be used for the Docker Hub `short-descript
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
- name: Docker Hub Description
|
- name: Docker Hub Description
|
||||||
uses: peter-evans/dockerhub-description@v2
|
uses: peter-evans/dockerhub-description@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
@@ -74,15 +83,16 @@ jobs:
|
|||||||
dockerHubDescription:
|
dockerHubDescription:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Docker Hub Description
|
- name: Docker Hub Description
|
||||||
uses: peter-evans/dockerhub-description@v2
|
uses: peter-evans/dockerhub-description@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
repository: peterevans/dockerhub-description
|
repository: peterevans/dockerhub-description
|
||||||
short-description: ${{ github.event.repository.description }}
|
short-description: ${{ github.event.repository.description }}
|
||||||
|
enable-url-completion: true
|
||||||
```
|
```
|
||||||
|
|
||||||
Updates the Docker Hub repository description whenever a new release is created.
|
Updates the Docker Hub repository description whenever a new release is created.
|
||||||
@@ -94,10 +104,10 @@ jobs:
|
|||||||
dockerHubDescription:
|
dockerHubDescription:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Docker Hub Description
|
- name: Docker Hub Description
|
||||||
uses: peter-evans/dockerhub-description@v2
|
uses: peter-evans/dockerhub-description@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
@@ -105,6 +115,38 @@ jobs:
|
|||||||
short-description: ${{ github.event.repository.description }}
|
short-description: ${{ github.event.repository.description }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### URL completion known Issues
|
||||||
|
|
||||||
|
The completion of relative URLs has some known issues:
|
||||||
|
|
||||||
|
1. Relative markdown links in inline-code and code blocks **are also converted**:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
[link in inline code](#table-of-content)
|
||||||
|
```
|
||||||
|
|
||||||
|
will be converted into
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
[link in inline code](https://github.com/peter-evans/dockerhub-description/blob/main/./README.md#table-of-content)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Links containing square brackets (`]`) in the text fragment **are not converted**:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
[[link text with square brackets]](#table-of-content)
|
||||||
|
```
|
||||||
|
|
||||||
|
3. [Reference-style links/images](https://www.markdownguide.org/basic-syntax/#reference-style-links) **are not converted**.
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
[table-of-content][toc]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
[toc]: #table-of-content "Table of content"
|
||||||
|
```
|
||||||
|
|
||||||
## Using the Docker image independently of GitHub Actions
|
## Using the Docker image independently of GitHub Actions
|
||||||
|
|
||||||
The image can be executed in other environments independently of GitHub Actions.
|
The image can be executed in other environments independently of GitHub Actions.
|
||||||
@@ -116,7 +158,7 @@ docker run -v $PWD:/workspace \
|
|||||||
-e DOCKERHUB_PASSWORD='xxxxx' \
|
-e DOCKERHUB_PASSWORD='xxxxx' \
|
||||||
-e DOCKERHUB_REPOSITORY='user1/my-docker-image' \
|
-e DOCKERHUB_REPOSITORY='user1/my-docker-image' \
|
||||||
-e README_FILEPATH='/workspace/README.md' \
|
-e README_FILEPATH='/workspace/README.md' \
|
||||||
peterevans/dockerhub-description:2
|
peterevans/dockerhub-description:3
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
28
__test__/input-helper.unit.test.ts
Normal file
28
__test__/input-helper.unit.test.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import {getInputs} from '../src/input-helper'
|
||||||
|
|
||||||
|
describe('input-helper tests', () => {
|
||||||
|
const ORIGINAL_ENV = process.env
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules()
|
||||||
|
process.env = {...ORIGINAL_ENV}
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
process.env = ORIGINAL_ENV
|
||||||
|
})
|
||||||
|
|
||||||
|
test('enableUrlCompletion should be false when "false" is passed', () => {
|
||||||
|
process.env['INPUT_ENABLE-URL-COMPLETION'] = 'false'
|
||||||
|
|
||||||
|
const inputs = getInputs()
|
||||||
|
expect(inputs.enableUrlCompletion).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('enableUrlCompletion should be true when "true" is passed', () => {
|
||||||
|
process.env['INPUT_ENABLE-URL-COMPLETION'] = 'true'
|
||||||
|
|
||||||
|
const inputs = getInputs()
|
||||||
|
expect(inputs.enableUrlCompletion).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
335
__test__/readme-helper.unit.test.ts
Normal file
335
__test__/readme-helper.unit.test.ts
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
import {completeRelativeUrls} from '../src/readme-helper'
|
||||||
|
|
||||||
|
describe('complete relative urls tests', () => {
|
||||||
|
const GITHUB_SERVER_URL = process.env['GITHUB_SERVER_URL']
|
||||||
|
const GITHUB_REPOSITORY = process.env['GITHUB_REPOSITORY']
|
||||||
|
const GITHUB_REF_NAME = process.env['GITHUB_REF_NAME']
|
||||||
|
|
||||||
|
const README_FILEPATH = './README.md'
|
||||||
|
const EXPECTED_REPOSITORY_URL = `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}`
|
||||||
|
const EXPECTED_BLOB_URL = `${EXPECTED_REPOSITORY_URL}/blob/${GITHUB_REF_NAME}`
|
||||||
|
const EXPECTED_RAW_URL = `${EXPECTED_REPOSITORY_URL}/raw/${GITHUB_REF_NAME}`
|
||||||
|
|
||||||
|
// known issues
|
||||||
|
test('reference-style links/image sources are not converted', async () => {
|
||||||
|
const content = [
|
||||||
|
'table-of-content][toc]',
|
||||||
|
'',
|
||||||
|
'[toc]: #table-of-content "Table of content"'
|
||||||
|
].join('\n')
|
||||||
|
expect(completeRelativeUrls(content, README_FILEPATH, true, '')).toEqual(
|
||||||
|
content
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('links containing square brackets in the text fragment are not converted', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[[text with square brackets]](README.md)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual('[[text with square brackets]](README.md)')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('links containing square brackets in the text fragment are not converted', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls('`[text](README.md)`', README_FILEPATH, true, '')
|
||||||
|
).toEqual(`\`[text](${EXPECTED_BLOB_URL}/README.md)\``)
|
||||||
|
})
|
||||||
|
|
||||||
|
// misc
|
||||||
|
test('do not change content when disabled', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls('[text](README.md)', README_FILEPATH, false, '')
|
||||||
|
).toEqual('[text](README.md)')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('do not change link with mailto protocol', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text](mailto:mail@example.com)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(`[text](mailto:mail@example.com)`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('do not change link with ftp protocol', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text](ftp://example.com)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(`[text](ftp://example.com)`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('do not change link with http protocol', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text](http://example.com)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(`[text](http://example.com)`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('do not change link with https protocol', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text](https://example.com)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(`[text](https://example.com)`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('do not change link with protocol-like beginning', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text](abc://example.com)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(`[text](abc://example.com)`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('do not change image from absolute source with absolute link', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[](https://example.com/image.svg)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
'svg'
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[](https://example.com/image.svg)`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
// anchors
|
||||||
|
test('anchor referencing the current document', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text](#relative-anchor)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(`[text](${EXPECTED_BLOB_URL}/README.md#relative-anchor)`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('anchor referencing the current document with a title', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text](#relative-anchor "the anchor (a title)")',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[text](${EXPECTED_BLOB_URL}/README.md#relative-anchor "the anchor (a title)")`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('anchor referencing the current document with a title and unicode', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text with 🌬](#relative-anchor "the anchor (a title with 🌬)")',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[text with 🌬](${EXPECTED_BLOB_URL}/README.md#relative-anchor "the anchor (a title with 🌬)")`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('anchor referencing another document', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text](OTHER.md#absolute-anchor)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(`[text](${EXPECTED_BLOB_URL}/OTHER.md#absolute-anchor)`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('anchor referencing another document with a title', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text](OTHER.md#absolute-anchor "the anchor (a title)")',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[text](${EXPECTED_BLOB_URL}/OTHER.md#absolute-anchor "the anchor (a title)")`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('anchor with image referencing the current document', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[](#absolute-anchor "the anchor (a title)")',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
'svg'
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[](${EXPECTED_BLOB_URL}/README.md#absolute-anchor "the anchor (a title)")`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('anchor with image referencing another document', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[](OTHER.md#absolute-anchor "the anchor (a title)")',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
'svg'
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[](${EXPECTED_BLOB_URL}/OTHER.md#absolute-anchor "the anchor (a title)")`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
// documents
|
||||||
|
test('text document', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls('[text](document.yaml)', README_FILEPATH, true, '')
|
||||||
|
).toEqual(`[text](${EXPECTED_BLOB_URL}/document.yaml)`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('pdf document', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls('[text](document.pdf)', README_FILEPATH, true, '')
|
||||||
|
).toEqual(`[text](${EXPECTED_BLOB_URL}/document.pdf)`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('document with a title', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text](document.pdf "the document (a title)")',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[text](${EXPECTED_BLOB_URL}/document.pdf "the document (a title)")`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('document with a title and unicode', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[text with 🌬](document.pdf "the document (a title with 🌬)")',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[text with 🌬](${EXPECTED_BLOB_URL}/document.pdf "the document (a title with 🌬)")`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
// images
|
||||||
|
test('image with supported file extension', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
'svg'
|
||||||
|
)
|
||||||
|
).toEqual(``)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('image with unsupported file extension', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
'jpeg'
|
||||||
|
)
|
||||||
|
).toEqual(``)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('image without alternate text', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls('', README_FILEPATH, true, 'svg')
|
||||||
|
).toEqual(``)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('image with a title', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'")',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
'svg'
|
||||||
|
)
|
||||||
|
).toEqual(`")`)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('image with relative link', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[](image.svg)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
'svg'
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[](${EXPECTED_BLOB_URL}/image.svg)`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('image with a title, unicode and relative link', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[")](image.🌬.svg)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
'svg'
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[")](${EXPECTED_BLOB_URL}/image.🌬.svg)`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('image from absolute source with relative link', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[](image.svg)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
'svg'
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[](${EXPECTED_BLOB_URL}/image.svg)`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('image with absolute link', async () => {
|
||||||
|
expect(
|
||||||
|
completeRelativeUrls(
|
||||||
|
'[](https://example.com/image.svg)',
|
||||||
|
README_FILEPATH,
|
||||||
|
true,
|
||||||
|
'svg'
|
||||||
|
)
|
||||||
|
).toEqual(
|
||||||
|
`[](https://example.com/image.svg)`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
10
__test__/utils.unit.test.ts
Normal file
10
__test__/utils.unit.test.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import {truncateToBytes} from '../src/utils'
|
||||||
|
|
||||||
|
describe('truncate to bytes tests', () => {
|
||||||
|
test('unicode aware truncation to a number of bytes', async () => {
|
||||||
|
expect(truncateToBytes('test string to be truncated', 10)).toEqual(
|
||||||
|
'test strin'
|
||||||
|
)
|
||||||
|
expect(truncateToBytes('😀😁😂🤣😃😄😅', 10)).toEqual('😀😁')
|
||||||
|
})
|
||||||
|
})
|
||||||
17
action.yml
17
action.yml
@@ -6,22 +6,29 @@ inputs:
|
|||||||
description: Docker Hub username
|
description: Docker Hub username
|
||||||
required: true
|
required: true
|
||||||
password:
|
password:
|
||||||
description: Docker Hub password
|
description: Docker Hub password or Personal Access Token with read/write/delete scope
|
||||||
required: true
|
required: true
|
||||||
repository:
|
repository:
|
||||||
description: >
|
description: >
|
||||||
Docker Hub repository in the format `<namespace>/<name>`
|
Docker Hub repository in the format `<namespace>/<name>`
|
||||||
Default: `github.repository`
|
Default: `github.repository`
|
||||||
short-description:
|
short-description:
|
||||||
description: >
|
description: Docker Hub repository short description
|
||||||
Docker Hub repository short description
|
|
||||||
Input exceeding 100 characters will be truncated
|
|
||||||
readme-filepath:
|
readme-filepath:
|
||||||
description: >
|
description: >
|
||||||
Path to the repository readme
|
Path to the repository readme
|
||||||
Default: `./README.md`
|
Default: `./README.md`
|
||||||
|
enable-url-completion:
|
||||||
|
description: >
|
||||||
|
Enables completion of relative URLs to absolute ones
|
||||||
|
Default: `false`
|
||||||
|
default: "false"
|
||||||
|
image-extensions:
|
||||||
|
description: >
|
||||||
|
File extensions that will be treated as images
|
||||||
|
Default: `bmp,gif,jpg,jpeg,png,svg,webp`
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
branding:
|
branding:
|
||||||
icon: 'upload'
|
icon: 'upload'
|
||||||
|
|||||||
5877
dist/index.js
vendored
5877
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/sh -l
|
#!/bin/sh -l
|
||||||
set -eo pipefail
|
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
# Execute the action code and output to file
|
# Execute the action code and output to file
|
||||||
node index.js > action.log 2>&1
|
node /index.js > action.log 2>&1
|
||||||
|
exit_code=$?
|
||||||
|
|
||||||
# Remove lines containing sensitive information from the log
|
# Remove lines containing sensitive information from the log
|
||||||
sed -i '/::debug::/d' ./action.log
|
sed -i '/::debug::/d' ./action.log
|
||||||
@@ -11,3 +11,6 @@ sed -i '/::add-mask::/d' ./action.log
|
|||||||
|
|
||||||
# Output the log
|
# Output the log
|
||||||
cat action.log
|
cat action.log
|
||||||
|
|
||||||
|
# Exit using the exit code of the node command
|
||||||
|
exit $exit_code
|
||||||
|
|||||||
@@ -9,3 +9,8 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
verbose: true
|
verbose: true
|
||||||
}
|
}
|
||||||
|
process.env = Object.assign(process.env, {
|
||||||
|
GITHUB_SERVER_URL: 'https://github.com',
|
||||||
|
GITHUB_REPOSITORY: 'peter-evans/dockerhub-description',
|
||||||
|
GITHUB_REF_NAME: 'main'
|
||||||
|
})
|
||||||
13383
package-lock.json
generated
13383
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
36
package.json
36
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dockerhub-description",
|
"name": "dockerhub-description",
|
||||||
"version": "3.0.0",
|
"version": "4.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "An action to update a Docker Hub repository description from README.md",
|
"description": "An action to update a Docker Hub repository description from README.md",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
"format": "prettier --write '**/*.ts'",
|
"format": "prettier --write '**/*.ts'",
|
||||||
"format-check": "prettier --check '**/*.ts'",
|
"format-check": "prettier --check '**/*.ts'",
|
||||||
"lint": "eslint src/**/*.ts",
|
"lint": "eslint src/**/*.ts",
|
||||||
"test": "jest --passWithNoTests"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -27,22 +27,24 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/peter-evans/dockerhub-description#readme",
|
"homepage": "https://github.com/peter-evans/dockerhub-description#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "1.3.0",
|
"@actions/core": "^1.11.1",
|
||||||
"node-fetch": "2.6.1"
|
"node-fetch": "^2.7.0",
|
||||||
|
"unicode-substring": "^0.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "26.0.23",
|
"@types/jest": "^27.0.3",
|
||||||
"@types/node": "15.6.1",
|
"@types/node": "^16.18.126",
|
||||||
"@typescript-eslint/parser": "4.25.0",
|
"@typescript-eslint/parser": "^5.62.0",
|
||||||
"@vercel/ncc": "0.28.6",
|
"@vercel/ncc": "^0.38.3",
|
||||||
"eslint": "7.27.0",
|
"eslint": "^8.57.1",
|
||||||
"eslint-plugin-github": "4.1.3",
|
"eslint-plugin-github": "^4.10.2",
|
||||||
"eslint-plugin-jest": "24.3.6",
|
"eslint-plugin-jest": "^25.7.0",
|
||||||
"jest": "27.0.1",
|
"eslint-plugin-prettier": "^5.2.5",
|
||||||
"jest-circus": "27.0.1",
|
"jest": "^27.5.1",
|
||||||
"js-yaml": "4.1.0",
|
"jest-circus": "^27.5.1",
|
||||||
"prettier": "2.3.0",
|
"js-yaml": "^4.1.0",
|
||||||
"ts-jest": "27.0.1",
|
"prettier": "^3.5.3",
|
||||||
"typescript": "4.3.2"
|
"ts-jest": "^27.1.5",
|
||||||
|
"typescript": "^4.9.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as fetch from 'node-fetch'
|
import * as fetch from 'node-fetch'
|
||||||
|
|
||||||
const DESCRIPTION_MAX_CHARS = 100
|
|
||||||
|
|
||||||
export async function getToken(
|
export async function getToken(
|
||||||
username: string,
|
username: string,
|
||||||
password: string
|
password: string
|
||||||
@@ -36,7 +34,7 @@ export async function updateRepositoryDescription(
|
|||||||
full_description: fullDescription
|
full_description: fullDescription
|
||||||
}
|
}
|
||||||
if (description) {
|
if (description) {
|
||||||
body['description'] = description.slice(0, DESCRIPTION_MAX_CHARS)
|
body['description'] = description
|
||||||
}
|
}
|
||||||
await fetch(`https://hub.docker.com/v2/repositories/${repository}`, {
|
await fetch(`https://hub.docker.com/v2/repositories/${repository}`, {
|
||||||
method: 'patch',
|
method: 'patch',
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import * as readmeHelper from './readme-helper'
|
||||||
const README_FILEPATH_DEFAULT = './README.md'
|
|
||||||
|
|
||||||
interface Inputs {
|
interface Inputs {
|
||||||
username: string
|
username: string
|
||||||
@@ -8,6 +7,8 @@ interface Inputs {
|
|||||||
repository: string
|
repository: string
|
||||||
shortDescription: string
|
shortDescription: string
|
||||||
readmeFilepath: string
|
readmeFilepath: string
|
||||||
|
enableUrlCompletion: boolean
|
||||||
|
imageExtensions: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInputs(): Inputs {
|
export function getInputs(): Inputs {
|
||||||
@@ -16,7 +17,9 @@ export function getInputs(): Inputs {
|
|||||||
password: core.getInput('password'),
|
password: core.getInput('password'),
|
||||||
repository: core.getInput('repository'),
|
repository: core.getInput('repository'),
|
||||||
shortDescription: core.getInput('short-description'),
|
shortDescription: core.getInput('short-description'),
|
||||||
readmeFilepath: core.getInput('readme-filepath')
|
readmeFilepath: core.getInput('readme-filepath'),
|
||||||
|
enableUrlCompletion: core.getBooleanInput('enable-url-completion'),
|
||||||
|
imageExtensions: core.getInput('image-extensions')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Environment variable input alternatives and their aliases
|
// Environment variable input alternatives and their aliases
|
||||||
@@ -50,16 +53,29 @@ export function getInputs(): Inputs {
|
|||||||
inputs.readmeFilepath = process.env['README_FILEPATH']
|
inputs.readmeFilepath = process.env['README_FILEPATH']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!inputs.enableUrlCompletion && process.env['ENABLE_URL_COMPLETION']) {
|
||||||
|
inputs.enableUrlCompletion =
|
||||||
|
process.env['ENABLE_URL_COMPLETION'].toLowerCase() === 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inputs.imageExtensions && process.env['IMAGE_EXTENSIONS']) {
|
||||||
|
inputs.imageExtensions = process.env['IMAGE_EXTENSIONS']
|
||||||
|
}
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
if (!inputs.readmeFilepath) {
|
if (!inputs.readmeFilepath) {
|
||||||
inputs.readmeFilepath = README_FILEPATH_DEFAULT
|
inputs.readmeFilepath = readmeHelper.README_FILEPATH_DEFAULT
|
||||||
|
}
|
||||||
|
if (!inputs.imageExtensions) {
|
||||||
|
inputs.imageExtensions = readmeHelper.IMAGE_EXTENSIONS_DEFAULT
|
||||||
}
|
}
|
||||||
if (!inputs.repository && process.env['GITHUB_REPOSITORY']) {
|
if (!inputs.repository && process.env['GITHUB_REPOSITORY']) {
|
||||||
inputs.repository = process.env['GITHUB_REPOSITORY']
|
inputs.repository = process.env['GITHUB_REPOSITORY']
|
||||||
}
|
}
|
||||||
|
|
||||||
// Docker repositories must be all lower case
|
// Enforce lower case, where needed
|
||||||
inputs.repository = inputs.repository.toLowerCase()
|
inputs.repository = inputs.repository.toLowerCase()
|
||||||
|
inputs.imageExtensions = inputs.imageExtensions.toLowerCase()
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
}
|
}
|
||||||
|
|||||||
35
src/main.ts
35
src/main.ts
@@ -1,10 +1,11 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as inputHelper from './input-helper'
|
import * as inputHelper from './input-helper'
|
||||||
import * as dockerhubHelper from './dockerhub-helper'
|
import * as dockerhubHelper from './dockerhub-helper'
|
||||||
import * as fs from 'fs'
|
import * as readmeHelper from './readme-helper'
|
||||||
import {inspect, TextEncoder} from 'util'
|
import * as utils from './utils'
|
||||||
|
import {inspect} from 'util'
|
||||||
|
|
||||||
const MAX_BYTES = 25000
|
const SHORT_DESCRIPTION_MAX_BYTES = 100
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
@@ -14,15 +15,25 @@ async function run(): Promise<void> {
|
|||||||
inputHelper.validateInputs(inputs)
|
inputHelper.validateInputs(inputs)
|
||||||
|
|
||||||
// Fetch the readme content
|
// Fetch the readme content
|
||||||
const readmeContent = await fs.promises.readFile(inputs.readmeFilepath, {
|
core.info('Reading description source file')
|
||||||
encoding: 'utf8'
|
const readmeContent = await readmeHelper.getReadmeContent(
|
||||||
})
|
inputs.readmeFilepath,
|
||||||
const byteLength = new TextEncoder().encode(readmeContent).length
|
inputs.enableUrlCompletion,
|
||||||
if (byteLength > MAX_BYTES) {
|
inputs.imageExtensions
|
||||||
throw new Error(
|
)
|
||||||
`File size exceeds the maximum allowed ${MAX_BYTES} bytes`
|
core.debug(readmeContent)
|
||||||
|
|
||||||
|
// Truncate the short description if it is too long
|
||||||
|
const truncatedShortDescription = utils.truncateToBytes(
|
||||||
|
inputs.shortDescription,
|
||||||
|
SHORT_DESCRIPTION_MAX_BYTES
|
||||||
|
)
|
||||||
|
if (truncatedShortDescription.length !== inputs.shortDescription.length) {
|
||||||
|
core.warning(
|
||||||
|
`The short description exceeds DockerHub's limit and has been truncated to ${SHORT_DESCRIPTION_MAX_BYTES} bytes.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
core.debug(`Truncated short description: ${truncatedShortDescription}`)
|
||||||
|
|
||||||
// Acquire a token for the Docker Hub API
|
// Acquire a token for the Docker Hub API
|
||||||
core.info('Acquiring token')
|
core.info('Acquiring token')
|
||||||
@@ -35,13 +46,13 @@ async function run(): Promise<void> {
|
|||||||
await dockerhubHelper.updateRepositoryDescription(
|
await dockerhubHelper.updateRepositoryDescription(
|
||||||
token,
|
token,
|
||||||
inputs.repository,
|
inputs.repository,
|
||||||
inputs.shortDescription,
|
truncatedShortDescription,
|
||||||
readmeContent
|
readmeContent
|
||||||
)
|
)
|
||||||
core.info('Request successful')
|
core.info('Request successful')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.debug(inspect(error))
|
core.debug(inspect(error))
|
||||||
core.setFailed(error.message)
|
core.setFailed(utils.getErrorMessage(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
184
src/readme-helper.ts
Normal file
184
src/readme-helper.ts
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
import * as core from '@actions/core'
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import * as utils from './utils'
|
||||||
|
|
||||||
|
export const README_FILEPATH_DEFAULT = './README.md'
|
||||||
|
export const IMAGE_EXTENSIONS_DEFAULT = 'bmp,gif,jpg,jpeg,png,svg,webp'
|
||||||
|
|
||||||
|
const TITLE_REGEX = `(?: +"[^"]+")?`
|
||||||
|
const REPOSITORY_URL = `${process.env['GITHUB_SERVER_URL']}/${process.env['GITHUB_REPOSITORY']}`
|
||||||
|
const BLOB_PREFIX = `${REPOSITORY_URL}/blob/${process.env['GITHUB_REF_NAME']}/`
|
||||||
|
const RAW_PREFIX = `${REPOSITORY_URL}/raw/${process.env['GITHUB_REF_NAME']}/`
|
||||||
|
|
||||||
|
const MAX_BYTES = 25000
|
||||||
|
|
||||||
|
type Rule = {
|
||||||
|
/**
|
||||||
|
* all left of the relative url belonging to the markdown image/link
|
||||||
|
*/
|
||||||
|
left: RegExp
|
||||||
|
/**
|
||||||
|
* relative url
|
||||||
|
*/
|
||||||
|
url: RegExp
|
||||||
|
/**
|
||||||
|
* part to prefix the relative url with (excluding github repository url)
|
||||||
|
*/
|
||||||
|
absUrlPrefix: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getReadmeContent(
|
||||||
|
readmeFilepath: string,
|
||||||
|
enableUrlCompletion: boolean,
|
||||||
|
imageExtensions: string
|
||||||
|
): Promise<string> {
|
||||||
|
// Fetch the readme content
|
||||||
|
let readmeContent = await fs.promises.readFile(readmeFilepath, {
|
||||||
|
encoding: 'utf8'
|
||||||
|
})
|
||||||
|
|
||||||
|
readmeContent = completeRelativeUrls(
|
||||||
|
readmeContent,
|
||||||
|
readmeFilepath,
|
||||||
|
enableUrlCompletion,
|
||||||
|
imageExtensions
|
||||||
|
)
|
||||||
|
|
||||||
|
const truncatedReadmeContent = utils.truncateToBytes(readmeContent, MAX_BYTES)
|
||||||
|
if (truncatedReadmeContent.length !== readmeContent.length) {
|
||||||
|
core.warning(
|
||||||
|
`The README content exceeds DockerHub's limit and has been truncated to ${MAX_BYTES} bytes.`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return truncatedReadmeContent
|
||||||
|
}
|
||||||
|
|
||||||
|
export function completeRelativeUrls(
|
||||||
|
readmeContent: string,
|
||||||
|
readmeFilepath: string,
|
||||||
|
enableUrlCompletion: boolean,
|
||||||
|
imageExtensions: string
|
||||||
|
): string {
|
||||||
|
if (enableUrlCompletion) {
|
||||||
|
readmeFilepath = readmeFilepath.replace(/^[.][/]/, '')
|
||||||
|
|
||||||
|
// Make relative urls absolute
|
||||||
|
const rules = [
|
||||||
|
...getRelativeReadmeAnchorsRules(readmeFilepath),
|
||||||
|
...getRelativeImageUrlRules(imageExtensions),
|
||||||
|
...getRelativeUrlRules()
|
||||||
|
]
|
||||||
|
|
||||||
|
readmeContent = applyRules(rules, readmeContent)
|
||||||
|
}
|
||||||
|
|
||||||
|
return readmeContent
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyRules(rules: Rule[], readmeContent: string): string {
|
||||||
|
rules.forEach(rule => {
|
||||||
|
const combinedRegex = `${rule.left.source}[(]${rule.url.source}[)]`
|
||||||
|
core.debug(`rule: ${combinedRegex}`)
|
||||||
|
|
||||||
|
const replacement = `$<left>(${rule.absUrlPrefix}$<url>)`
|
||||||
|
core.debug(`replacement: ${replacement}`)
|
||||||
|
|
||||||
|
readmeContent = readmeContent.replace(
|
||||||
|
new RegExp(combinedRegex, 'giu'),
|
||||||
|
replacement
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
return readmeContent
|
||||||
|
}
|
||||||
|
|
||||||
|
// has to be applied first to avoid wrong results
|
||||||
|
function getRelativeReadmeAnchorsRules(readmeFilepath: string): Rule[] {
|
||||||
|
const prefix = `${BLOB_PREFIX}${readmeFilepath}`
|
||||||
|
|
||||||
|
// matches e.g.:
|
||||||
|
// #table-of-content
|
||||||
|
// #table-of-content "the anchor (a title)"
|
||||||
|
const url = new RegExp(`(?<url>#[^)]+${TITLE_REGEX})`)
|
||||||
|
|
||||||
|
const rules: Rule[] = [
|
||||||
|
// matches e.g.:
|
||||||
|
// [#table-of-content](#table-of-content)
|
||||||
|
// [#table-of-content](#table-of-content "the anchor (a title)")
|
||||||
|
{
|
||||||
|
left: /(?<left>\[[^\]]+\])/,
|
||||||
|
url: url,
|
||||||
|
absUrlPrefix: prefix
|
||||||
|
},
|
||||||
|
|
||||||
|
// matches e.g.:
|
||||||
|
// [](#table-of-content)
|
||||||
|
// [](#table-of-content "title b")
|
||||||
|
{
|
||||||
|
left: /(?<left>\[!\[[^\]]*\]\([^)]+\)\])/,
|
||||||
|
url: url,
|
||||||
|
absUrlPrefix: prefix
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
return rules
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRelativeImageUrlRules(imageExtensions: string): Rule[] {
|
||||||
|
const extensionsRegex = imageExtensions.replace(/,/g, '|')
|
||||||
|
// matches e.g.:
|
||||||
|
// media/image.svg
|
||||||
|
// media/image.svg "with title"
|
||||||
|
const url = new RegExp(
|
||||||
|
`(?<url>[^:)]+[.](?:${extensionsRegex})${TITLE_REGEX})`
|
||||||
|
)
|
||||||
|
|
||||||
|
const rules: Rule[] = [
|
||||||
|
// matches e.g.:
|
||||||
|
// 
|
||||||
|
// 
|
||||||
|
{
|
||||||
|
left: /(?<left>!\[[^\]]*\])/,
|
||||||
|
url: url,
|
||||||
|
absUrlPrefix: RAW_PREFIX
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
return rules
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRelativeUrlRules(): Rule[] {
|
||||||
|
// matches e.g.:
|
||||||
|
// .releaserc.yaml
|
||||||
|
// README.md#table-of-content "title b"
|
||||||
|
// .releaserc.yaml "the .releaserc.yaml file (a title)"
|
||||||
|
const url = new RegExp(`(?<url>[^:)]+${TITLE_REGEX})`)
|
||||||
|
|
||||||
|
const rules: Rule[] = [
|
||||||
|
// matches e.g.:
|
||||||
|
// [.releaserc.yaml](.releaserc.yaml)
|
||||||
|
// [.releaserc.yaml](.releaserc.yaml "the .releaserc.yaml file (a title)")
|
||||||
|
{
|
||||||
|
left: /(?<left>\[[^\]]+\])/,
|
||||||
|
url: url,
|
||||||
|
absUrlPrefix: BLOB_PREFIX
|
||||||
|
},
|
||||||
|
|
||||||
|
// matches e.g.:
|
||||||
|
// [](media/image.svg)
|
||||||
|
// [](README.md#table-of-content "title b")
|
||||||
|
// [](media/image.svg)
|
||||||
|
// [](media/image.svg "title b")
|
||||||
|
// [](README.md#table-of-content "title b")
|
||||||
|
{
|
||||||
|
left: new RegExp(
|
||||||
|
`(?<left>\\[!\\[[^\\]]*\\]\\([^)]+${TITLE_REGEX}\\)\\])`
|
||||||
|
),
|
||||||
|
url: url,
|
||||||
|
absUrlPrefix: BLOB_PREFIX
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
return rules
|
||||||
|
}
|
||||||
14
src/utils.ts
Normal file
14
src/utils.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import unicodeSubstring = require('unicode-substring')
|
||||||
|
|
||||||
|
export function getErrorMessage(error: unknown) {
|
||||||
|
if (error instanceof Error) return error.message
|
||||||
|
return String(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function truncateToBytes(s: string, n: number): string {
|
||||||
|
let len = n
|
||||||
|
while (Buffer.byteLength(s) > n) {
|
||||||
|
s = unicodeSubstring(s, 0, len--)
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user