fix: improve log messages for token creation (#226)
Updated log messages to provide clearer and more consistent information.
This commit is contained in:
+15
-16
@@ -21,7 +21,7 @@ export async function main(
|
|||||||
core,
|
core,
|
||||||
createAppAuth,
|
createAppAuth,
|
||||||
request,
|
request,
|
||||||
skipTokenRevoke,
|
skipTokenRevoke
|
||||||
) {
|
) {
|
||||||
let parsedOwner = "";
|
let parsedOwner = "";
|
||||||
let parsedRepositoryNames = [];
|
let parsedRepositoryNames = [];
|
||||||
@@ -33,7 +33,7 @@ export async function main(
|
|||||||
parsedRepositoryNames = [repo];
|
parsedRepositoryNames = [repo];
|
||||||
|
|
||||||
core.info(
|
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;
|
parsedOwner = owner;
|
||||||
|
|
||||||
core.info(
|
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;
|
parsedRepositoryNames = repositories;
|
||||||
|
|
||||||
core.info(
|
core.info(
|
||||||
`owner not set, creating owner for given repositories "${repositories.join(
|
`No 'owner' input provided. Using default owner '${parsedOwner}' to create token for the following repositories:${repositories
|
||||||
",",
|
.map((repo) => `\n- ${parsedOwner}/${repo}`)
|
||||||
)}" in current owner ("${parsedOwner}")`,
|
.join("")}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,9 +64,8 @@ export async function main(
|
|||||||
parsedRepositoryNames = repositories;
|
parsedRepositoryNames = repositories;
|
||||||
|
|
||||||
core.info(
|
core.info(
|
||||||
`owner and repositories set, creating token for repositories "${repositories.join(
|
`Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:
|
||||||
",",
|
${repositories.map((repo) => `\n- ${parsedOwner}/${repo}`).join("")}`
|
||||||
)}" owned by "${owner}"`,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,18 +86,18 @@ export async function main(
|
|||||||
auth,
|
auth,
|
||||||
parsedOwner,
|
parsedOwner,
|
||||||
parsedRepositoryNames,
|
parsedRepositoryNames,
|
||||||
permissions,
|
permissions
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
onFailedAttempt: (error) => {
|
onFailedAttempt: (error) => {
|
||||||
core.info(
|
core.info(
|
||||||
`Failed to create token for "${parsedRepositoryNames.join(
|
`Failed to create token for "${parsedRepositoryNames.join(
|
||||||
",",
|
","
|
||||||
)}" (attempt ${error.attemptNumber}): ${error.message}`,
|
)}" (attempt ${error.attemptNumber}): ${error.message}`
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
retries: 3,
|
retries: 3,
|
||||||
},
|
}
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
// Otherwise get the installation for the owner, which can either be an organization or a user account
|
// 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) => {
|
onFailedAttempt: (error) => {
|
||||||
core.info(
|
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,
|
retries: 3,
|
||||||
},
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +156,7 @@ async function getTokenFromRepository(
|
|||||||
auth,
|
auth,
|
||||||
parsedOwner,
|
parsedOwner,
|
||||||
parsedRepositoryNames,
|
parsedRepositoryNames,
|
||||||
permissions,
|
permissions
|
||||||
) {
|
) {
|
||||||
// https://docs.github.com/rest/apps/apps?apiVersion=2022-11-28#get-a-repository-installation-for-the-authenticated-app
|
// 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", {
|
const response = await request("GET /repos/{owner}/{repo}/installation", {
|
||||||
|
|||||||
+29
-12
@@ -22,7 +22,9 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
@@ -65,7 +67,7 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
@@ -89,7 +91,9 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
@@ -113,7 +117,7 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
Failed to create token for "smockle" (attempt 1): GitHub API not available␊
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
@@ -138,7 +142,9 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
Failed to create token for "failed-repo" (attempt 1): GitHub API not available␊
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
@@ -163,7 +169,11 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
@@ -186,7 +196,11 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
@@ -209,7 +223,9 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
@@ -232,7 +248,7 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
@@ -255,7 +271,8 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
@@ -278,7 +295,7 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
@@ -301,7 +318,7 @@ Generated by [AVA](https://avajs.dev).
|
|||||||
|
|
||||||
> stdout
|
> 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␊
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
␊
|
␊
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user