feat: v5 (#327)
Some checks failed
Publish Docker Image / publish (push) Has been cancelled

* feat: update runtime to node 24

* fix: deps

* feat: update create token endpoint (#311)

/v2/users/login was deprecated in favor of using /v2/auth/token to create access tokens. Switching endpoints adds support for creating auth tokens from OATs.

* fix: use correct response property

* feat: switch to native fetch

* fix: method name

---------

Co-authored-by: Ian Pittwood <pittwoodian@gmail.com>
This commit is contained in:
Peter Evans
2025-10-01 14:39:49 +01:00
committed by GitHub
parent ef9b19a328
commit 1b9a80c056
10 changed files with 1843 additions and 6586 deletions

View File

@@ -14,5 +14,10 @@
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/camelcase": "off"
},
"settings": {
"import/resolver": {
"typescript": {}
}
}
}

View File

@@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 20.x
node-version-file: package.json
cache: npm
- run: npm ci
- run: npm run build

View File

@@ -11,7 +11,7 @@ on:
type: choice
description: The major version tag to update
options:
- v4
- v5
jobs:
tag:

View File

@@ -11,7 +11,7 @@ This is useful if you `docker push` your images to Docker Hub. It provides an ea
- uses: actions/checkout@v4
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v4
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -44,7 +44,7 @@ If this is not the case the path can be specified with the `readme-filepath` inp
```yml
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v4
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -58,7 +58,7 @@ The GitHub repository description can be used for the Docker Hub `short-descript
```yml
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v4
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -86,7 +86,7 @@ jobs:
- uses: actions/checkout@v4
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v4
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -107,7 +107,7 @@ jobs:
- uses: actions/checkout@v4
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v4
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

View File

@@ -27,7 +27,7 @@ inputs:
File extensions that will be treated as images
Default: `bmp,gif,jpg,jpeg,png,svg,webp`
runs:
using: 'node20'
using: 'node24'
main: 'dist/index.js'
branding:
icon: 'upload'

4194
dist/index.js vendored

File diff suppressed because one or more lines are too long

4170
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,12 @@
{
"name": "dockerhub-description",
"version": "4.0.0",
"version": "5.0.0",
"private": true,
"description": "An action to update a Docker Hub repository description from README.md",
"main": "lib/main.js",
"engines": {
"node": ">=24.4.0"
},
"scripts": {
"build": "tsc && ncc build",
"format": "prettier --write '**/*.ts'",
@@ -28,23 +31,24 @@
"homepage": "https://github.com/peter-evans/dockerhub-description#readme",
"dependencies": {
"@actions/core": "^1.11.1",
"node-fetch": "^2.7.0",
"unicode-substring": "^0.1.0"
},
"devDependencies": {
"@types/jest": "^27.0.3",
"@types/jest": "^29.0.0",
"@types/node": "^16.18.126",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vercel/ncc": "^0.38.4",
"eslint": "^8.57.1",
"eslint-import-resolver-typescript": "^3.10.1",
"eslint-plugin-github": "^4.10.2",
"eslint-plugin-jest": "^25.7.0",
"eslint-plugin-jest": "^28.0.0",
"eslint-plugin-prettier": "^5.5.4",
"jest": "^27.5.1",
"jest-circus": "^27.5.1",
"jest": "^29.0.0",
"jest-circus": "^29.0.0",
"js-yaml": "^4.1.0",
"prettier": "^3.6.2",
"ts-jest": "^27.1.5",
"ts-jest": "^29.0.0",
"typescript": "^4.9.5"
}
}

View File

@@ -1,16 +1,15 @@
import * as core from '@actions/core'
import * as fetch from 'node-fetch'
export async function getToken(
username: string,
password: string
): Promise<string> {
const body = {
username: username,
password: password
identifier: username,
secret: password
}
const response = await fetch('https://hub.docker.com/v2/users/login', {
method: 'post',
const response = await fetch('https://hub.docker.com/v2/auth/token', {
method: 'POST',
body: JSON.stringify(body),
headers: {'Content-Type': 'application/json'}
})
@@ -20,8 +19,8 @@ export async function getToken(
)
}
const json = await response.json()
core.setSecret(json['token'])
return json['token']
core.setSecret(json['access_token'])
return json['access_token']
}
export async function updateRepositoryDescription(
@@ -37,11 +36,11 @@ export async function updateRepositoryDescription(
body['description'] = description
}
await fetch(`https://hub.docker.com/v2/repositories/${repository}`, {
method: 'patch',
method: 'PATCH',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json',
Authorization: `JWT ${token}`
Authorization: `Bearer ${token}`
}
}).then(res => {
if (!res.ok) {

View File

@@ -3,7 +3,8 @@
"target": "es6",
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"outDir": "./lib",
"rootDir": "./src",