From afa309ec72b6cebd058f73d4d8d34160c32c2df0 Mon Sep 17 00:00:00 2001 From: Peter Evans <18365890+peter-evans@users.noreply.github.com> Date: Thu, 18 Aug 2022 12:17:06 +0900 Subject: [PATCH] feat: remove error when content limit exceeded --- README.md | 7 ++++++- action.yml | 4 +--- dist/index.js | 5 ----- src/main.ts | 10 +--------- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 6b631b7..d5ec57f 100644 --- a/README.md +++ b/README.md @@ -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. | | | `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 `/`. | `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` | +#### 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 The action assumes that there is a file called `README.md` located at the root of the repository. diff --git a/action.yml b/action.yml index 569ed72..24f56b1 100644 --- a/action.yml +++ b/action.yml @@ -13,9 +13,7 @@ inputs: Docker Hub repository in the format `/` Default: `github.repository` short-description: - description: > - Docker Hub repository short description - Input exceeding 100 characters will be truncated + description: Docker Hub repository short description readme-filepath: description: > Path to the repository readme diff --git a/dist/index.js b/dist/index.js index 674ce34..8b6c541 100644 --- a/dist/index.js +++ b/dist/index.js @@ -212,7 +212,6 @@ const inputHelper = __importStar(__nccwpck_require__(480)); const dockerhubHelper = __importStar(__nccwpck_require__(812)); const fs = __importStar(__nccwpck_require__(147)); const util_1 = __nccwpck_require__(837); -const MAX_BYTES = 25000; function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -223,10 +222,6 @@ function run() { const readmeContent = yield fs.promises.readFile(inputs.readmeFilepath, { 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 core.info('Acquiring token'); const token = yield dockerhubHelper.getToken(inputs.username, inputs.password); diff --git a/src/main.ts b/src/main.ts index fee7899..ed90337 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,9 +2,7 @@ import * as core from '@actions/core' import * as inputHelper from './input-helper' import * as dockerhubHelper from './dockerhub-helper' import * as fs from 'fs' -import {inspect, TextEncoder} from 'util' - -const MAX_BYTES = 25000 +import {inspect} from 'util' async function run(): Promise { try { @@ -17,12 +15,6 @@ async function run(): Promise { const readmeContent = await fs.promises.readFile(inputs.readmeFilepath, { 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 core.info('Acquiring token')