mirror of
https://github.com/peter-evans/dockerhub-description.git
synced 2024-11-29 07:29:33 +01:00
Merge pull request #71 from peter-evans/rm-byte-limit
feat: remove error when content limit exceeded
This commit is contained in:
commit
da890086d3
4 changed files with 8 additions and 18 deletions
|
@ -23,9 +23,14 @@ This is useful if you `docker push` your images to Docker Hub. It provides an ea
|
||||||
| `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 or [Personal Access Token](https://docs.docker.com/docker-hub/access-tokens/) with `read/write/delete` scope. | |
|
| `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` |
|
||||||
|
|
||||||
|
#### Content limits
|
||||||
|
|
||||||
|
DockerHub has content limits, which if exceeded will result in the content being automatically truncated.
|
||||||
|
The readme content is limited to 25,000 bytes, and `short-description` is limited to 100 characters.
|
||||||
|
|
||||||
#### Specifying the file path
|
#### Specifying the file path
|
||||||
|
|
||||||
The action assumes that there is a file called `README.md` located at the root of the repository.
|
The action assumes that there is a file called `README.md` located at the root of the repository.
|
||||||
|
|
|
@ -13,9 +13,7 @@ inputs:
|
||||||
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
|
||||||
|
|
5
dist/index.js
vendored
5
dist/index.js
vendored
|
@ -212,7 +212,6 @@ const inputHelper = __importStar(__nccwpck_require__(480));
|
||||||
const dockerhubHelper = __importStar(__nccwpck_require__(812));
|
const dockerhubHelper = __importStar(__nccwpck_require__(812));
|
||||||
const fs = __importStar(__nccwpck_require__(147));
|
const fs = __importStar(__nccwpck_require__(147));
|
||||||
const util_1 = __nccwpck_require__(837);
|
const util_1 = __nccwpck_require__(837);
|
||||||
const MAX_BYTES = 25000;
|
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
@ -223,10 +222,6 @@ function run() {
|
||||||
const readmeContent = yield fs.promises.readFile(inputs.readmeFilepath, {
|
const readmeContent = yield fs.promises.readFile(inputs.readmeFilepath, {
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
});
|
});
|
||||||
const byteLength = new util_1.TextEncoder().encode(readmeContent).length;
|
|
||||||
if (byteLength > MAX_BYTES) {
|
|
||||||
throw new Error(`File size exceeds the maximum allowed ${MAX_BYTES} bytes`);
|
|
||||||
}
|
|
||||||
// Acquire a token for the Docker Hub API
|
// Acquire a token for the Docker Hub API
|
||||||
core.info('Acquiring token');
|
core.info('Acquiring token');
|
||||||
const token = yield dockerhubHelper.getToken(inputs.username, inputs.password);
|
const token = yield dockerhubHelper.getToken(inputs.username, inputs.password);
|
||||||
|
|
10
src/main.ts
10
src/main.ts
|
@ -2,9 +2,7 @@ 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 fs from 'fs'
|
||||||
import {inspect, TextEncoder} from 'util'
|
import {inspect} from 'util'
|
||||||
|
|
||||||
const MAX_BYTES = 25000
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
@ -17,12 +15,6 @@ async function run(): Promise<void> {
|
||||||
const readmeContent = await fs.promises.readFile(inputs.readmeFilepath, {
|
const readmeContent = await fs.promises.readFile(inputs.readmeFilepath, {
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
})
|
})
|
||||||
const byteLength = new TextEncoder().encode(readmeContent).length
|
|
||||||
if (byteLength > MAX_BYTES) {
|
|
||||||
throw new Error(
|
|
||||||
`File size exceeds the maximum allowed ${MAX_BYTES} bytes`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Acquire a token for the Docker Hub API
|
// Acquire a token for the Docker Hub API
|
||||||
core.info('Acquiring token')
|
core.info('Acquiring token')
|
||||||
|
|
Loading…
Reference in a new issue