From 8601eaa971773ba4e02140144e7303133c816e4a Mon Sep 17 00:00:00 2001 From: Parker Brown <17183625+parkerbxyz@users.noreply.github.com> Date: Thu, 3 Apr 2025 11:28:33 -0700 Subject: [PATCH 1/3] refactor: improve log messages for token creation --- lib/main.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/main.js b/lib/main.js index 3440d9a..f07947f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ export async function main( core, createAppAuth, request, - skipTokenRevoke, + skipTokenRevoke ) { let parsedOwner = ""; let parsedRepositoryNames = []; @@ -33,7 +33,7 @@ export async function main( parsedRepositoryNames = [repo]; core.info( - `owner and repositories not set, creating token for the current repository ("${repo}")`, + `Inputs 'owner' and 'repositories' are not set. Creating token for this repository (${owner}/${repo}).` ); } @@ -42,7 +42,7 @@ export async function main( parsedOwner = owner; core.info( - `repositories not set, creating token for all repositories for given owner "${owner}"`, + `Input 'repositories' is not set. Creating token for all repositories owned by ${owner}.` ); } @@ -52,9 +52,9 @@ export async function main( parsedRepositoryNames = repositories; core.info( - `owner not set, creating owner for given repositories "${repositories.join( - ",", - )}" in current owner ("${parsedOwner}")`, + `No 'owner' input provided. Using default owner '${parsedOwner}' to create token for the following repositories:${repositories + .map((repo) => `\n- ${parsedOwner}/${repo}`) + .join("")}` ); } @@ -64,9 +64,8 @@ export async function main( parsedRepositoryNames = repositories; core.info( - `owner and repositories set, creating token for repositories "${repositories.join( - ",", - )}" owned by "${owner}"`, + `Inputs 'owner' and 'repositories' are set. Creating token for the following repositories: + ${repositories.map((repo) => `\n- ${parsedOwner}/${repo}`).join("")}` ); } @@ -87,18 +86,18 @@ export async function main( auth, parsedOwner, parsedRepositoryNames, - permissions, + permissions ), { onFailedAttempt: (error) => { core.info( `Failed to create token for "${parsedRepositoryNames.join( - ",", - )}" (attempt ${error.attemptNumber}): ${error.message}`, + "," + )}" (attempt ${error.attemptNumber}): ${error.message}` ); }, retries: 3, - }, + } )); } else { // Otherwise get the installation for the owner, which can either be an organization or a user account @@ -107,11 +106,11 @@ export async function main( { onFailedAttempt: (error) => { core.info( - `Failed to create token for "${parsedOwner}" (attempt ${error.attemptNumber}): ${error.message}`, + `Failed to create token for "${parsedOwner}" (attempt ${error.attemptNumber}): ${error.message}` ); }, retries: 3, - }, + } )); } @@ -157,7 +156,7 @@ async function getTokenFromRepository( auth, parsedOwner, parsedRepositoryNames, - permissions, + permissions ) { // https://docs.github.com/rest/apps/apps?apiVersion=2022-11-28#get-a-repository-installation-for-the-authenticated-app const response = await request("GET /repos/{owner}/{repo}/installation", { From 195e0cab0f1a5749f8cb8e7fdd338d2291483c34 Mon Sep 17 00:00:00 2001 From: Parker Brown <17183625+parkerbxyz@users.noreply.github.com> Date: Thu, 3 Apr 2025 15:44:07 -0700 Subject: [PATCH 2/3] Update snapshots --- tests/snapshots/index.js.md | 41 ++++++++++++++++++++++++---------- tests/snapshots/index.js.snap | Bin 1511 -> 1560 bytes 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/tests/snapshots/index.js.md b/tests/snapshots/index.js.md index f085f87..979df5a 100644 --- a/tests/snapshots/index.js.md +++ b/tests/snapshots/index.js.md @@ -24,7 +24,9 @@ Generated by [AVA](https://avajs.dev). > stdout - `owner and repositories set, creating token for repositories "create-github-app-token" owned by "actions"␊ + `Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊ + ␊ + - actions/create-github-app-token␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ ::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ @@ -87,7 +89,7 @@ Generated by [AVA](https://avajs.dev). > stdout - `owner and repositories not set, creating token for the current repository ("create-github-app-token")␊ + `Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ ::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ @@ -111,7 +113,9 @@ Generated by [AVA](https://avajs.dev). > stdout - `owner and repositories set, creating token for repositories "failed-repo" owned by "actions"␊ + `Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊ + ␊ + - actions/failed-repo␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ ::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ @@ -135,7 +139,7 @@ Generated by [AVA](https://avajs.dev). > stdout - `repositories not set, creating token for all repositories for given owner "smockle"␊ + `Input 'repositories' is not set. Creating token for all repositories owned by smockle.␊ Failed to create token for "smockle" (attempt 1): GitHub API not available␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ @@ -160,7 +164,9 @@ Generated by [AVA](https://avajs.dev). > stdout - `owner and repositories set, creating token for repositories "failed-repo" owned by "actions"␊ + `Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊ + ␊ + - actions/failed-repo␊ Failed to create token for "failed-repo" (attempt 1): GitHub API not available␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ @@ -185,7 +191,11 @@ Generated by [AVA](https://avajs.dev). > stdout - `owner and repositories set, creating token for repositories "create-github-app-token,toolkit,checkout" owned by "actions"␊ + `Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊ + ␊ + - actions/create-github-app-token␊ + - actions/toolkit␊ + - actions/checkout␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ ::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ @@ -208,7 +218,11 @@ Generated by [AVA](https://avajs.dev). > stdout - `owner and repositories set, creating token for repositories "create-github-app-token,toolkit,checkout" owned by "actions"␊ + `Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊ + ␊ + - actions/create-github-app-token␊ + - actions/toolkit␊ + - actions/checkout␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ ::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ @@ -231,7 +245,9 @@ Generated by [AVA](https://avajs.dev). > stdout - `owner and repositories set, creating token for repositories "create-github-app-token" owned by "actions"␊ + `Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊ + ␊ + - actions/create-github-app-token␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ ::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ @@ -254,7 +270,7 @@ Generated by [AVA](https://avajs.dev). > stdout - `repositories not set, creating token for all repositories for given owner "actions"␊ + `Input 'repositories' is not set. Creating token for all repositories owned by actions.␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ ::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ @@ -277,7 +293,8 @@ Generated by [AVA](https://avajs.dev). > stdout - `owner not set, creating owner for given repositories "create-github-app-token" in current owner ("actions")␊ + `No 'owner' input provided. Using default owner 'actions' to create token for the following repositories:␊ + - actions/create-github-app-token␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ ::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ @@ -300,7 +317,7 @@ Generated by [AVA](https://avajs.dev). > stdout - `owner and repositories not set, creating token for the current repository ("create-github-app-token")␊ + `Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ ::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ @@ -323,7 +340,7 @@ Generated by [AVA](https://avajs.dev). > stdout - `owner and repositories not set, creating token for the current repository ("create-github-app-token")␊ + `Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).␊ ::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ ␊ ::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊ diff --git a/tests/snapshots/index.js.sn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6)qzo9Y8s#>#=KU*;VB*v=6Ny_=Hjg@Reh#K zA(M))id`Ue84tj>Gf-X>{ddkxO+(g=&(pS`bJHl~TpGm-P<)TjGdVZtQImahGF5<~ z6bMBYAk5J1FPwVWVL^~(+Z^oi5eO1H#KEET1_3ygn|7pTU5=|&D$1l0S!7znFw~@Z z*-abYXka781J((k^v6Z{BSKKvNM>V(Cyx35xqKj^AehPeaxUw3xjHxCf6oB_+r^gi zy4$r$ftRL?f^F>QKWa8lPR;7qk!LwYaZZge(%7P?7YEkfV78T!6V3hGhp;^R}oPFYF0m~08e z5f&#fff^&LMzTe8cd+~wmj+qi% z^jvq(GHyEcY*I-4tkNa3U!t)RV{P&5<-gr?vZ~dLs>N7J61GOnD|O-2hEs_%_rg=c z3YClfOBqpbO!G4U|HPbF&4qIEVW#_ck4%r*WlwsUspjpJnt~Sq`|oA6ycuiZlS-NC N{~wy7L-4LD002Tg_Xz+1 From bbf615f9075766928842671742961c6cc2c37e6f Mon Sep 17 00:00:00 2001 From: Parker Brown <17183625+parkerbxyz@users.noreply.github.com> Date: Thu, 3 Apr 2025 15:46:52 -0700 Subject: [PATCH 3/3] Update index.js.snap --- tests/snapshots/index.js.snap | Bin 1560 -> 1392 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/snapshots/index.js.snap b/tests/snapshots/index.js.snap index 7ee115420fa3d6ba3e35e352f48c6f32ee936ea9..e66c3d55e1416e7ac7aff4b1d2b5c4e6ce80213f 100644 GIT binary patch literal 1392 zcmV-$1&{hcRzV2cAp#eV`4rF+~)(D+`!8) z#NI{WyB~`P00000000B+THS8rL=5tp)YH=>wIGH); zn={|{jmMK0?Uv(NJ^uSK2qqkON~k56=jt~20a#RktuxmT1uqHUqVywY+@(J6dV>FQ zY}-`O@7|hwXHLH6-=6zm4jkG7r_F^8K`^_47mAatTAwmkw?ZzwzTRP?8@6=nGd&EP ztLHsj_%+#NVX&~RMna0-(1oB#sB4pA0KUhW@B#)LKMH_w5G8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