@@ -42,7 +42,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
4242exports . updateRepositoryDescription = exports . getToken = void 0 ;
4343const core = __importStar ( __nccwpck_require__ ( 2186 ) ) ;
4444const fetch = __importStar ( __nccwpck_require__ ( 467 ) ) ;
45- const DESCRIPTION_MAX_CHARS = 100 ;
4645function getToken ( username , password ) {
4746 return __awaiter ( this , void 0 , void 0 , function * ( ) {
4847 const body = {
@@ -69,7 +68,7 @@ function updateRepositoryDescription(token, repository, description, fullDescrip
6968 full_description : fullDescription
7069 } ;
7170 if ( description ) {
72- body [ 'description' ] = description . slice ( 0 , DESCRIPTION_MAX_CHARS ) ;
71+ body [ 'description' ] = description ;
7372 }
7473 yield fetch ( `https://hub.docker.com/v2/repositories/${ repository } ` , {
7574 method : 'patch' ,
@@ -238,12 +237,9 @@ const core = __importStar(__nccwpck_require__(2186));
238237const inputHelper = __importStar ( __nccwpck_require__ ( 5480 ) ) ;
239238const dockerhubHelper = __importStar ( __nccwpck_require__ ( 1812 ) ) ;
240239const readmeHelper = __importStar ( __nccwpck_require__ ( 3367 ) ) ;
240+ const utils = __importStar ( __nccwpck_require__ ( 918 ) ) ;
241241const util_1 = __nccwpck_require__ ( 3837 ) ;
242- function getErrorMessage ( error ) {
243- if ( error instanceof Error )
244- return error . message ;
245- return String ( error ) ;
246- }
242+ const SHORT_DESCRIPTION_MAX_BYTES = 100 ;
247243function run ( ) {
248244 return __awaiter ( this , void 0 , void 0 , function * ( ) {
249245 try {
@@ -254,6 +250,11 @@ function run() {
254250 core . info ( 'Reading description source file' ) ;
255251 const readmeContent = yield readmeHelper . getReadmeContent ( inputs . readmeFilepath , inputs . enableUrlCompletion , inputs . imageExtensions ) ;
256252 core . debug ( readmeContent ) ;
253+ // Truncate the short description if it is too long
254+ const truncatedShortDescription = utils . truncateToBytes ( inputs . shortDescription , SHORT_DESCRIPTION_MAX_BYTES ) ;
255+ if ( truncatedShortDescription . length !== inputs . shortDescription . length ) {
256+ core . warning ( `The short description exceeds DockerHub's limit and has been truncated to ${ SHORT_DESCRIPTION_MAX_BYTES } bytes.` ) ;
257+ }
257258 // Acquire a token for the Docker Hub API
258259 core . info ( 'Acquiring token' ) ;
259260 const token = yield dockerhubHelper . getToken ( inputs . username , inputs . password ) ;
@@ -264,7 +265,7 @@ function run() {
264265 }
265266 catch ( error ) {
266267 core . debug ( ( 0 , util_1 . inspect ) ( error ) ) ;
267- core . setFailed ( getErrorMessage ( error ) ) ;
268+ core . setFailed ( utils . getErrorMessage ( error ) ) ;
268269 }
269270 } ) ;
270271}
@@ -311,10 +312,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
311312 } ) ;
312313} ;
313314Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
314- exports . completeRelativeUrls = exports . getReadmeContent = exports . truncateToBytes = exports . ENABLE_URL_COMPLETION_DEFAULT = exports . IMAGE_EXTENSIONS_DEFAULT = exports . README_FILEPATH_DEFAULT = void 0 ;
315+ exports . completeRelativeUrls = exports . getReadmeContent = exports . ENABLE_URL_COMPLETION_DEFAULT = exports . IMAGE_EXTENSIONS_DEFAULT = exports . README_FILEPATH_DEFAULT = void 0 ;
315316const core = __importStar ( __nccwpck_require__ ( 2186 ) ) ;
316317const fs = __importStar ( __nccwpck_require__ ( 7147 ) ) ;
317- const unicodeSubstring = __nccwpck_require__ ( 6986 ) ;
318+ const utils = __importStar ( __nccwpck_require__ ( 918 ) ) ;
318319exports . README_FILEPATH_DEFAULT = './README.md' ;
319320exports . IMAGE_EXTENSIONS_DEFAULT = 'bmp,gif,jpg,jpeg,png,svg,webp' ;
320321exports . ENABLE_URL_COMPLETION_DEFAULT = false ;
@@ -323,22 +324,14 @@ const REPOSITORY_URL = `${process.env['GITHUB_SERVER_URL']}/${process.env['GITHU
323324const BLOB_PREFIX = `${ REPOSITORY_URL } /blob/${ process . env [ 'GITHUB_REF_NAME' ] } /` ;
324325const RAW_PREFIX = `${ REPOSITORY_URL } /raw/${ process . env [ 'GITHUB_REF_NAME' ] } /` ;
325326const MAX_BYTES = 25000 ;
326- function truncateToBytes ( s , n ) {
327- let len = n ;
328- while ( Buffer . byteLength ( s ) > n ) {
329- s = unicodeSubstring ( s , 0 , len -- ) ;
330- }
331- return s ;
332- }
333- exports . truncateToBytes = truncateToBytes ;
334327function getReadmeContent ( readmeFilepath , enableUrlCompletion , imageExtensions ) {
335328 return __awaiter ( this , void 0 , void 0 , function * ( ) {
336329 // Fetch the readme content
337330 let readmeContent = yield fs . promises . readFile ( readmeFilepath , {
338331 encoding : 'utf8'
339332 } ) ;
340333 readmeContent = completeRelativeUrls ( readmeContent , readmeFilepath , enableUrlCompletion , imageExtensions ) ;
341- const truncatedReadmeContent = truncateToBytes ( readmeContent , MAX_BYTES ) ;
334+ const truncatedReadmeContent = utils . truncateToBytes ( readmeContent , MAX_BYTES ) ;
342335 if ( truncatedReadmeContent . length !== readmeContent . length ) {
343336 core . warning ( `The README content exceeds DockerHub's limit and has been truncated to ${ MAX_BYTES } bytes.` ) ;
344337 }
@@ -446,6 +439,32 @@ function getRelativeUrlRules() {
446439}
447440
448441
442+ /***/ } ) ,
443+
444+ /***/ 918 :
445+ /***/ ( ( __unused_webpack_module , exports , __nccwpck_require__ ) => {
446+
447+ "use strict" ;
448+
449+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
450+ exports . truncateToBytes = exports . getErrorMessage = void 0 ;
451+ const unicodeSubstring = __nccwpck_require__ ( 6986 ) ;
452+ function getErrorMessage ( error ) {
453+ if ( error instanceof Error )
454+ return error . message ;
455+ return String ( error ) ;
456+ }
457+ exports . getErrorMessage = getErrorMessage ;
458+ function truncateToBytes ( s , n ) {
459+ let len = n ;
460+ while ( Buffer . byteLength ( s ) > n ) {
461+ s = unicodeSubstring ( s , 0 , len -- ) ;
462+ }
463+ return s ;
464+ }
465+ exports . truncateToBytes = truncateToBytes ;
466+
467+
449468/***/ } ) ,
450469
451470/***/ 7351 :
0 commit comments