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

@@ -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) {