Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
202973a37c | ||
|
|
728b36f7bb | ||
|
|
3f60feb215 | ||
|
|
812a4d0496 |
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:
|
||||||
|
- v3
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tag:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
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
|
||||||
@@ -30,8 +30,10 @@ This is useful if you `docker push` your images to Docker Hub. It provides an ea
|
|||||||
|
|
||||||
#### Content limits
|
#### Content limits
|
||||||
|
|
||||||
DockerHub has content limits, which if exceeded will result in the content being automatically truncated.
|
DockerHub has content limits.
|
||||||
The readme content is limited to 25,000 bytes, and `short-description` is limited to 100 characters.
|
The readme content is limited to 25,000 bytes, and `short-description` is limited to 100 characters.
|
||||||
|
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
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {completeRelativeUrls} from '../src/readme-helper'
|
import {completeRelativeUrls, truncateToBytes} from '../src/readme-helper'
|
||||||
|
|
||||||
describe('complete relative urls tests', () => {
|
describe('complete relative urls tests', () => {
|
||||||
const GITHUB_SERVER_URL = process.env['GITHUB_SERVER_URL']
|
const GITHUB_SERVER_URL = process.env['GITHUB_SERVER_URL']
|
||||||
@@ -333,3 +333,12 @@ describe('complete relative urls tests', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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('😀😁')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
76
dist/index.js
vendored
76
dist/index.js
vendored
@@ -311,9 +311,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.completeRelativeUrls = exports.getReadmeContent = exports.ENABLE_URL_COMPLETION_DEFAULT = exports.IMAGE_EXTENSIONS_DEFAULT = exports.README_FILEPATH_DEFAULT = void 0;
|
exports.completeRelativeUrls = exports.getReadmeContent = exports.truncateToBytes = exports.ENABLE_URL_COMPLETION_DEFAULT = exports.IMAGE_EXTENSIONS_DEFAULT = exports.README_FILEPATH_DEFAULT = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
|
const unicodeSubstring = __nccwpck_require__(6986);
|
||||||
exports.README_FILEPATH_DEFAULT = './README.md';
|
exports.README_FILEPATH_DEFAULT = './README.md';
|
||||||
exports.IMAGE_EXTENSIONS_DEFAULT = 'bmp,gif,jpg,jpeg,png,svg,webp';
|
exports.IMAGE_EXTENSIONS_DEFAULT = 'bmp,gif,jpg,jpeg,png,svg,webp';
|
||||||
exports.ENABLE_URL_COMPLETION_DEFAULT = false;
|
exports.ENABLE_URL_COMPLETION_DEFAULT = false;
|
||||||
@@ -321,6 +322,15 @@ const TITLE_REGEX = `(?: +"[^"]+")?`;
|
|||||||
const REPOSITORY_URL = `${process.env['GITHUB_SERVER_URL']}/${process.env['GITHUB_REPOSITORY']}`;
|
const REPOSITORY_URL = `${process.env['GITHUB_SERVER_URL']}/${process.env['GITHUB_REPOSITORY']}`;
|
||||||
const BLOB_PREFIX = `${REPOSITORY_URL}/blob/${process.env['GITHUB_REF_NAME']}/`;
|
const BLOB_PREFIX = `${REPOSITORY_URL}/blob/${process.env['GITHUB_REF_NAME']}/`;
|
||||||
const RAW_PREFIX = `${REPOSITORY_URL}/raw/${process.env['GITHUB_REF_NAME']}/`;
|
const RAW_PREFIX = `${REPOSITORY_URL}/raw/${process.env['GITHUB_REF_NAME']}/`;
|
||||||
|
const MAX_BYTES = 25000;
|
||||||
|
function truncateToBytes(s, n) {
|
||||||
|
let len = n;
|
||||||
|
while (Buffer.byteLength(s) > n) {
|
||||||
|
s = unicodeSubstring(s, 0, len--);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
exports.truncateToBytes = truncateToBytes;
|
||||||
function getReadmeContent(readmeFilepath, enableUrlCompletion, imageExtensions) {
|
function getReadmeContent(readmeFilepath, enableUrlCompletion, imageExtensions) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// Fetch the readme content
|
// Fetch the readme content
|
||||||
@@ -328,7 +338,11 @@ function getReadmeContent(readmeFilepath, enableUrlCompletion, imageExtensions)
|
|||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
});
|
});
|
||||||
readmeContent = completeRelativeUrls(readmeContent, readmeFilepath, enableUrlCompletion, imageExtensions);
|
readmeContent = completeRelativeUrls(readmeContent, readmeFilepath, enableUrlCompletion, imageExtensions);
|
||||||
return readmeContent;
|
const truncatedReadmeContent = 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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getReadmeContent = getReadmeContent;
|
exports.getReadmeContent = getReadmeContent;
|
||||||
@@ -6430,6 +6444,64 @@ if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
|
|||||||
exports.debug = debug; // for test
|
exports.debug = debug; // for test
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6986:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
function charAt(string, index) {
|
||||||
|
var first = string.charCodeAt(index);
|
||||||
|
var second;
|
||||||
|
if (first >= 55296 && first <= 56319 && string.length > index + 1) {
|
||||||
|
second = string.charCodeAt(index + 1);
|
||||||
|
if (second >= 56320 && second <= 57343) {
|
||||||
|
return string.substring(index, index + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
function slice(string, start, end) {
|
||||||
|
var accumulator = "";
|
||||||
|
var character;
|
||||||
|
var stringIndex = 0;
|
||||||
|
var unicodeIndex = 0;
|
||||||
|
var length = string.length;
|
||||||
|
|
||||||
|
while (stringIndex < length) {
|
||||||
|
character = charAt(string, stringIndex);
|
||||||
|
if (unicodeIndex >= start && unicodeIndex < end) {
|
||||||
|
accumulator += character;
|
||||||
|
}
|
||||||
|
stringIndex += character.length;
|
||||||
|
unicodeIndex += 1;
|
||||||
|
}
|
||||||
|
return accumulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toNumber(value, fallback) {
|
||||||
|
if (value === undefined) {
|
||||||
|
return fallback;
|
||||||
|
} else {
|
||||||
|
return Number(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function (string, start, end) {
|
||||||
|
var realStart = toNumber(start, 0);
|
||||||
|
var realEnd = toNumber(end, string.length);
|
||||||
|
if (realEnd == realStart) {
|
||||||
|
return "";
|
||||||
|
} else if (realEnd > realStart) {
|
||||||
|
return slice(string, realStart, realEnd);
|
||||||
|
} else {
|
||||||
|
return slice(string, realEnd, realStart);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 5840:
|
/***/ 5840:
|
||||||
|
|||||||
5174
package-lock.json
generated
5174
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -28,12 +28,13 @@
|
|||||||
"homepage": "https://github.com/peter-evans/dockerhub-description#readme",
|
"homepage": "https://github.com/peter-evans/dockerhub-description#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"node-fetch": "^2.6.9"
|
"node-fetch": "^2.6.9",
|
||||||
|
"unicode-substring": "^0.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.0.3",
|
"@types/jest": "^27.0.3",
|
||||||
"@types/node": "^16.18.12",
|
"@types/node": "^16.18.14",
|
||||||
"@typescript-eslint/parser": "^5.53.0",
|
"@typescript-eslint/parser": "^5.54.0",
|
||||||
"@vercel/ncc": "^0.36.1",
|
"@vercel/ncc": "^0.36.1",
|
||||||
"eslint": "^8.35.0",
|
"eslint": "^8.35.0",
|
||||||
"eslint-plugin-github": "^4.6.1",
|
"eslint-plugin-github": "^4.6.1",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
import unicodeSubstring = require('unicode-substring')
|
||||||
|
|
||||||
export const README_FILEPATH_DEFAULT = './README.md'
|
export const README_FILEPATH_DEFAULT = './README.md'
|
||||||
export const IMAGE_EXTENSIONS_DEFAULT = 'bmp,gif,jpg,jpeg,png,svg,webp'
|
export const IMAGE_EXTENSIONS_DEFAULT = 'bmp,gif,jpg,jpeg,png,svg,webp'
|
||||||
@@ -10,6 +11,8 @@ const REPOSITORY_URL = `${process.env['GITHUB_SERVER_URL']}/${process.env['GITHU
|
|||||||
const BLOB_PREFIX = `${REPOSITORY_URL}/blob/${process.env['GITHUB_REF_NAME']}/`
|
const BLOB_PREFIX = `${REPOSITORY_URL}/blob/${process.env['GITHUB_REF_NAME']}/`
|
||||||
const RAW_PREFIX = `${REPOSITORY_URL}/raw/${process.env['GITHUB_REF_NAME']}/`
|
const RAW_PREFIX = `${REPOSITORY_URL}/raw/${process.env['GITHUB_REF_NAME']}/`
|
||||||
|
|
||||||
|
const MAX_BYTES = 25000
|
||||||
|
|
||||||
type Rule = {
|
type Rule = {
|
||||||
/**
|
/**
|
||||||
* all left of the relative url belonging to the markdown image/link
|
* all left of the relative url belonging to the markdown image/link
|
||||||
@@ -25,6 +28,14 @@ type Rule = {
|
|||||||
absUrlPrefix: string
|
absUrlPrefix: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function truncateToBytes(s: string, n: number): string {
|
||||||
|
let len = n
|
||||||
|
while (Buffer.byteLength(s) > n) {
|
||||||
|
s = unicodeSubstring(s, 0, len--)
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
export async function getReadmeContent(
|
export async function getReadmeContent(
|
||||||
readmeFilepath: string,
|
readmeFilepath: string,
|
||||||
enableUrlCompletion: boolean,
|
enableUrlCompletion: boolean,
|
||||||
@@ -42,7 +53,14 @@ export async function getReadmeContent(
|
|||||||
imageExtensions
|
imageExtensions
|
||||||
)
|
)
|
||||||
|
|
||||||
return readmeContent
|
const truncatedReadmeContent = 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(
|
export function completeRelativeUrls(
|
||||||
|
|||||||
Reference in New Issue
Block a user