Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea0d3155e4 | |||
| 37f42c53d0 | |||
| 8204e76db8 | |||
| e9da44231a |
@@ -0,0 +1,17 @@
|
|||||||
|
name: 'Publish Immutable Action'
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Publish Immutable Action
|
||||||
|
uses: actions/publish-immutable-action@v0.0.4
|
||||||
@@ -9,8 +9,10 @@ GitHub Action for creating a GitHub App installation access token.
|
|||||||
In order to use this action, you need to:
|
In order to use this action, you need to:
|
||||||
|
|
||||||
1. [Register new GitHub App](https://docs.github.com/apps/creating-github-apps/setting-up-a-github-app/creating-a-github-app).
|
1. [Register new GitHub App](https://docs.github.com/apps/creating-github-apps/setting-up-a-github-app/creating-a-github-app).
|
||||||
2. [Store the App's Client ID in your repository environment variables](https://docs.github.com/actions/how-tos/write-workflows/choose-what-workflows-do/use-variables#defining-configuration-variables-for-multiple-workflows) (example: `GITHUB_APP_CLIENT_ID`).
|
2. [Store the App's Client ID in your repository environment variables](https://docs.github.com/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows) (example: `APP_CLIENT_ID`).
|
||||||
3. [Store the App's private key in your repository secrets](https://docs.github.com/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets?tool=webui#creating-secrets-for-a-repository) (example: `GITHUB_APP_PRIVATE_KEY`).
|
3. [Store the App's private key in your repository secrets](https://docs.github.com/actions/security-guides/encrypted-secrets?tool=webui#creating-encrypted-secrets-for-a-repository) (example: `PRIVATE_KEY`).
|
||||||
|
|
||||||
|
Pass the App's Client ID using the `client-id` input. The legacy `app-id` input remains available for compatibility, but is deprecated.
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> An installation access token expires after 1 hour. Please [see this comment](https://github.com/actions/create-github-app-token/issues/121#issuecomment-2043214796) for alternative approaches if you have long-running processes.
|
> An installation access token expires after 1 hour. Please [see this comment](https://github.com/actions/create-github-app-token/issues/121#issuecomment-2043214796) for alternative approaches if you have long-running processes.
|
||||||
@@ -31,8 +33,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
- uses: ./actions/staging-tests
|
- uses: ./actions/staging-tests
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.app-token.outputs.token }}
|
token: ${{ steps.app-token.outputs.token }}
|
||||||
@@ -51,8 +53,8 @@ jobs:
|
|||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
# required
|
# required
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.app-token.outputs.token }}
|
token: ${{ steps.app-token.outputs.token }}
|
||||||
@@ -77,8 +79,8 @@ jobs:
|
|||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
# required
|
# required
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
- name: Get GitHub App User ID
|
- name: Get GitHub App User ID
|
||||||
id: get-user-id
|
id: get-user-id
|
||||||
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
|
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
|
||||||
@@ -102,8 +104,8 @@ jobs:
|
|||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
# required
|
# required
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
- name: Get GitHub App User ID
|
- name: Get GitHub App User ID
|
||||||
id: get-user-id
|
id: get-user-id
|
||||||
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
|
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
|
||||||
@@ -138,8 +140,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
owner: ${{ github.repository_owner }}
|
owner: ${{ github.repository_owner }}
|
||||||
- uses: peter-evans/create-or-update-comment@v4
|
- uses: peter-evans/create-or-update-comment@v4
|
||||||
with:
|
with:
|
||||||
@@ -160,8 +162,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
owner: ${{ github.repository_owner }}
|
owner: ${{ github.repository_owner }}
|
||||||
repositories: |
|
repositories: |
|
||||||
repo1
|
repo1
|
||||||
@@ -185,8 +187,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
owner: another-owner
|
owner: another-owner
|
||||||
- uses: peter-evans/create-or-update-comment@v4
|
- uses: peter-evans/create-or-update-comment@v4
|
||||||
with:
|
with:
|
||||||
@@ -210,8 +212,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
owner: ${{ github.repository_owner }}
|
owner: ${{ github.repository_owner }}
|
||||||
permission-issues: write
|
permission-issues: write
|
||||||
- uses: peter-evans/create-or-update-comment@v4
|
- uses: peter-evans/create-or-update-comment@v4
|
||||||
@@ -252,8 +254,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
owner: ${{ matrix.owners-and-repos.owner }}
|
owner: ${{ matrix.owners-and-repos.owner }}
|
||||||
repositories: ${{ join(matrix.owners-and-repos.repos) }}
|
repositories: ${{ join(matrix.owners-and-repos.repos) }}
|
||||||
- uses: octokit/request-action@v2.x
|
- uses: octokit/request-action@v2.x
|
||||||
@@ -310,18 +312,24 @@ If you set `HTTP_PROXY` or `HTTPS_PROXY`, also set `NODE_USE_ENV_PROXY: "1"` on
|
|||||||
NO_PROXY: github.example.com
|
NO_PROXY: github.example.com
|
||||||
NODE_USE_ENV_PROXY: "1"
|
NODE_USE_ENV_PROXY: "1"
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
### `client-id` or `app-id`
|
### `client-id`
|
||||||
|
|
||||||
**Required:** GitHub App Client ID.
|
**Optional:** GitHub App Client ID. This is the recommended input.
|
||||||
|
|
||||||
> [!NOTE]
|
### `app-id`
|
||||||
> The legacy `app-id` input is also accepted, but `client-id` is recommended.
|
|
||||||
|
**Optional:** GitHub App ID.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> `app-id` is deprecated. Use `client-id` instead.
|
||||||
|
|
||||||
|
You must set either `client-id` or `app-id`. If both are set, `client-id` takes precedence.
|
||||||
|
|
||||||
### `private-key`
|
### `private-key`
|
||||||
|
|
||||||
@@ -334,14 +342,14 @@ steps:
|
|||||||
- name: Decode the GitHub App Private Key
|
- name: Decode the GitHub App Private Key
|
||||||
id: decode
|
id: decode
|
||||||
run: |
|
run: |
|
||||||
private_key=$(echo "${{ secrets.GITHUB_APP_PRIVATE_KEY }}" | base64 -d | awk 'BEGIN {ORS="\\n"} {print}' | head -c -2) &> /dev/null
|
private_key=$(echo "${{ secrets.PRIVATE_KEY }}" | base64 -d | awk 'BEGIN {ORS="\\n"} {print}' | head -c -2) &> /dev/null
|
||||||
echo "::add-mask::$private_key"
|
echo "::add-mask::$private_key"
|
||||||
echo "private-key=$private_key" >> "$GITHUB_OUTPUT"
|
echo "private-key=$private_key" >> "$GITHUB_OUTPUT"
|
||||||
- name: Generate GitHub App Token
|
- name: Generate GitHub App Token
|
||||||
id: app-token
|
id: app-token
|
||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ steps.decode.outputs.private-key }}
|
private-key: ${{ steps.decode.outputs.private-key }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -35,10 +35,6 @@ inputs:
|
|||||||
description: "The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts. Can be set to 'read' or 'write'."
|
description: "The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts. Can be set to 'read' or 'write'."
|
||||||
permission-administration:
|
permission-administration:
|
||||||
description: "The level of permission to grant the access token for repository creation, deletion, settings, teams, and collaborators creation. Can be set to 'read' or 'write'."
|
description: "The level of permission to grant the access token for repository creation, deletion, settings, teams, and collaborators creation. Can be set to 'read' or 'write'."
|
||||||
permission-artifact-metadata:
|
|
||||||
description: "The level of permission to grant the access token to create and retrieve build artifact metadata records. Can be set to 'read' or 'write'."
|
|
||||||
permission-attestations:
|
|
||||||
description: "The level of permission to create and retrieve the access token for repository attestations. Can be set to 'read' or 'write'."
|
|
||||||
permission-checks:
|
permission-checks:
|
||||||
description: "The level of permission to grant the access token for checks on code. Can be set to 'read' or 'write'."
|
description: "The level of permission to grant the access token for checks on code. Can be set to 'read' or 'write'."
|
||||||
permission-codespaces:
|
permission-codespaces:
|
||||||
@@ -51,8 +47,6 @@ inputs:
|
|||||||
description: "The level of permission to grant the access token to manage Dependabot secrets. Can be set to 'read' or 'write'."
|
description: "The level of permission to grant the access token to manage Dependabot secrets. Can be set to 'read' or 'write'."
|
||||||
permission-deployments:
|
permission-deployments:
|
||||||
description: "The level of permission to grant the access token for deployments and deployment statuses. Can be set to 'read' or 'write'."
|
description: "The level of permission to grant the access token for deployments and deployment statuses. Can be set to 'read' or 'write'."
|
||||||
permission-discussions:
|
|
||||||
description: "The level of permission to grant the access token for discussions and related comments and labels. Can be set to 'read' or 'write'."
|
|
||||||
permission-email-addresses:
|
permission-email-addresses:
|
||||||
description: "The level of permission to grant the access token to manage the email addresses belonging to a user. Can be set to 'read' or 'write'."
|
description: "The level of permission to grant the access token to manage the email addresses belonging to a user. Can be set to 'read' or 'write'."
|
||||||
permission-enterprise-custom-properties-for-organizations:
|
permission-enterprise-custom-properties-for-organizations:
|
||||||
@@ -71,8 +65,6 @@ inputs:
|
|||||||
description: "The level of permission to grant the access token for issues and related comments, assignees, labels, and milestones. Can be set to 'read' or 'write'."
|
description: "The level of permission to grant the access token for issues and related comments, assignees, labels, and milestones. Can be set to 'read' or 'write'."
|
||||||
permission-members:
|
permission-members:
|
||||||
description: "The level of permission to grant the access token for organization teams and members. Can be set to 'read' or 'write'."
|
description: "The level of permission to grant the access token for organization teams and members. Can be set to 'read' or 'write'."
|
||||||
permission-merge-queues:
|
|
||||||
description: "The level of permission to grant the access token to manage the merge queues for a repository. Can be set to 'read' or 'write'."
|
|
||||||
permission-metadata:
|
permission-metadata:
|
||||||
description: "The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata. Can be set to 'read' or 'write'."
|
description: "The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata. Can be set to 'read' or 'write'."
|
||||||
permission-organization-administration:
|
permission-organization-administration:
|
||||||
|
|||||||
Vendored
+35
-78
@@ -22964,37 +22964,30 @@ var isError = (value) => objectToString.call(value) === "[object Error]";
|
|||||||
var errorMessages = /* @__PURE__ */ new Set([
|
var errorMessages = /* @__PURE__ */ new Set([
|
||||||
"network error",
|
"network error",
|
||||||
// Chrome
|
// Chrome
|
||||||
|
"Failed to fetch",
|
||||||
|
// Chrome
|
||||||
"NetworkError when attempting to fetch resource.",
|
"NetworkError when attempting to fetch resource.",
|
||||||
// Firefox
|
// Firefox
|
||||||
"The Internet connection appears to be offline.",
|
"The Internet connection appears to be offline.",
|
||||||
// Safari 16
|
// Safari 16
|
||||||
|
"Load failed",
|
||||||
|
// Safari 17+
|
||||||
"Network request failed",
|
"Network request failed",
|
||||||
// `cross-fetch`
|
// `cross-fetch`
|
||||||
"fetch failed",
|
"fetch failed",
|
||||||
// Undici (Node.js)
|
// Undici (Node.js)
|
||||||
"terminated",
|
"terminated"
|
||||||
// Undici (Node.js)
|
// Undici (Node.js)
|
||||||
" A network error occurred.",
|
|
||||||
// Bun (WebKit)
|
|
||||||
"Network connection lost"
|
|
||||||
// Cloudflare Workers (fetch)
|
|
||||||
]);
|
]);
|
||||||
function isNetworkError(error2) {
|
function isNetworkError(error2) {
|
||||||
const isValid = error2 && isError(error2) && error2.name === "TypeError" && typeof error2.message === "string";
|
const isValid = error2 && isError(error2) && error2.name === "TypeError" && typeof error2.message === "string";
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const { message, stack } = error2;
|
if (error2.message === "Load failed") {
|
||||||
if (message === "Load failed") {
|
return error2.stack === void 0;
|
||||||
return stack === void 0 || "__sentry_captured__" in error2;
|
|
||||||
}
|
}
|
||||||
if (message.startsWith("error sending request for url")) {
|
return errorMessages.has(error2.message);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (message === "Failed to fetch" || message.startsWith("Failed to fetch (") && message.endsWith(")")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return errorMessages.has(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// node_modules/p-retry/index.js
|
// node_modules/p-retry/index.js
|
||||||
@@ -23024,14 +23017,6 @@ function validateNumberOption(name, value, { min = 0, allowInfinity = false } =
|
|||||||
throw new TypeError(`Expected \`${name}\` to be \u2265 ${min}.`);
|
throw new TypeError(`Expected \`${name}\` to be \u2265 ${min}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function validateFunctionOption(name, value) {
|
|
||||||
if (value === void 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (typeof value !== "function") {
|
|
||||||
throw new TypeError(`Expected \`${name}\` to be a function.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var AbortError = class extends Error {
|
var AbortError = class extends Error {
|
||||||
constructor(message) {
|
constructor(message) {
|
||||||
super();
|
super();
|
||||||
@@ -23059,26 +23044,6 @@ function calculateRemainingTime(start, max) {
|
|||||||
}
|
}
|
||||||
return max - (performance.now() - start);
|
return max - (performance.now() - start);
|
||||||
}
|
}
|
||||||
async function delayForRetry(delay, options) {
|
|
||||||
if (delay <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await new Promise((resolve2, reject) => {
|
|
||||||
const onAbort = () => {
|
|
||||||
clearTimeout(timeoutToken);
|
|
||||||
options.signal?.removeEventListener("abort", onAbort);
|
|
||||||
reject(options.signal.reason);
|
|
||||||
};
|
|
||||||
const timeoutToken = setTimeout(() => {
|
|
||||||
options.signal?.removeEventListener("abort", onAbort);
|
|
||||||
resolve2();
|
|
||||||
}, delay);
|
|
||||||
if (options.unref) {
|
|
||||||
timeoutToken.unref?.();
|
|
||||||
}
|
|
||||||
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async function onAttemptFailure({ error: error2, attemptNumber, retriesConsumed, startTime, options }) {
|
async function onAttemptFailure({ error: error2, attemptNumber, retriesConsumed, startTime, options }) {
|
||||||
const normalizedError = error2 instanceof Error ? error2 : new TypeError(`Non-error was thrown: "${error2}". You should only throw errors.`);
|
const normalizedError = error2 instanceof Error ? error2 : new TypeError(`Non-error was thrown: "${error2}". You should only throw errors.`);
|
||||||
if (normalizedError instanceof AbortError) {
|
if (normalizedError instanceof AbortError) {
|
||||||
@@ -23086,60 +23051,55 @@ async function onAttemptFailure({ error: error2, attemptNumber, retriesConsumed,
|
|||||||
}
|
}
|
||||||
const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
|
const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
|
||||||
const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
|
const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
|
||||||
const delayTime = calculateDelay(retriesConsumed, options);
|
|
||||||
const remainingTimeBeforeCallbacks = calculateRemainingTime(startTime, maxRetryTime);
|
|
||||||
if (remainingTimeBeforeCallbacks <= 0) {
|
|
||||||
const context2 = Object.freeze({
|
|
||||||
error: normalizedError,
|
|
||||||
attemptNumber,
|
|
||||||
retriesLeft,
|
|
||||||
retriesConsumed,
|
|
||||||
retryDelay: 0
|
|
||||||
});
|
|
||||||
await options.onFailedAttempt(context2);
|
|
||||||
throw normalizedError;
|
|
||||||
}
|
|
||||||
const consumeRetryContext = Object.freeze({
|
|
||||||
error: normalizedError,
|
|
||||||
attemptNumber,
|
|
||||||
retriesLeft,
|
|
||||||
retriesConsumed,
|
|
||||||
retryDelay: retriesLeft > 0 ? delayTime : 0
|
|
||||||
});
|
|
||||||
const consumeRetry = await options.shouldConsumeRetry(consumeRetryContext);
|
|
||||||
const effectiveDelay = consumeRetry && retriesLeft > 0 ? delayTime : 0;
|
|
||||||
const context = Object.freeze({
|
const context = Object.freeze({
|
||||||
error: normalizedError,
|
error: normalizedError,
|
||||||
attemptNumber,
|
attemptNumber,
|
||||||
retriesLeft,
|
retriesLeft,
|
||||||
retriesConsumed,
|
retriesConsumed
|
||||||
retryDelay: effectiveDelay
|
|
||||||
});
|
});
|
||||||
await options.onFailedAttempt(context);
|
await options.onFailedAttempt(context);
|
||||||
if (calculateRemainingTime(startTime, maxRetryTime) <= 0) {
|
if (calculateRemainingTime(startTime, maxRetryTime) <= 0) {
|
||||||
throw normalizedError;
|
throw normalizedError;
|
||||||
}
|
}
|
||||||
|
const consumeRetry = await options.shouldConsumeRetry(context);
|
||||||
const remainingTime = calculateRemainingTime(startTime, maxRetryTime);
|
const remainingTime = calculateRemainingTime(startTime, maxRetryTime);
|
||||||
if (remainingTime <= 0 || retriesLeft <= 0) {
|
if (remainingTime <= 0 || retriesLeft <= 0) {
|
||||||
throw normalizedError;
|
throw normalizedError;
|
||||||
}
|
}
|
||||||
if (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {
|
if (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {
|
||||||
throw normalizedError;
|
if (consumeRetry) {
|
||||||
|
throw normalizedError;
|
||||||
|
}
|
||||||
|
options.signal?.throwIfAborted();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (!await options.shouldRetry(context)) {
|
if (!await options.shouldRetry(context)) {
|
||||||
throw normalizedError;
|
throw normalizedError;
|
||||||
}
|
}
|
||||||
const remainingTimeAfterShouldRetry = calculateRemainingTime(startTime, maxRetryTime);
|
|
||||||
if (remainingTimeAfterShouldRetry <= 0) {
|
|
||||||
throw normalizedError;
|
|
||||||
}
|
|
||||||
if (!consumeRetry) {
|
if (!consumeRetry) {
|
||||||
options.signal?.throwIfAborted();
|
options.signal?.throwIfAborted();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const finalDelay = Math.min(effectiveDelay, remainingTimeAfterShouldRetry);
|
const delayTime = calculateDelay(retriesConsumed, options);
|
||||||
|
const finalDelay = Math.min(delayTime, remainingTime);
|
||||||
options.signal?.throwIfAborted();
|
options.signal?.throwIfAborted();
|
||||||
await delayForRetry(finalDelay, options);
|
if (finalDelay > 0) {
|
||||||
|
await new Promise((resolve2, reject) => {
|
||||||
|
const onAbort = () => {
|
||||||
|
clearTimeout(timeoutToken);
|
||||||
|
options.signal?.removeEventListener("abort", onAbort);
|
||||||
|
reject(options.signal.reason);
|
||||||
|
};
|
||||||
|
const timeoutToken = setTimeout(() => {
|
||||||
|
options.signal?.removeEventListener("abort", onAbort);
|
||||||
|
resolve2();
|
||||||
|
}, finalDelay);
|
||||||
|
if (options.unref) {
|
||||||
|
timeoutToken.unref?.();
|
||||||
|
}
|
||||||
|
options.signal?.addEventListener("abort", onAbort, { once: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
options.signal?.throwIfAborted();
|
options.signal?.throwIfAborted();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -23159,9 +23119,6 @@ async function pRetry(input, options = {}) {
|
|||||||
};
|
};
|
||||||
options.shouldRetry ??= () => true;
|
options.shouldRetry ??= () => true;
|
||||||
options.shouldConsumeRetry ??= () => true;
|
options.shouldConsumeRetry ??= () => true;
|
||||||
validateFunctionOption("onFailedAttempt", options.onFailedAttempt);
|
|
||||||
validateFunctionOption("shouldRetry", options.shouldRetry);
|
|
||||||
validateFunctionOption("shouldConsumeRetry", options.shouldConsumeRetry);
|
|
||||||
validateNumberOption("factor", options.factor, { min: 0, allowInfinity: false });
|
validateNumberOption("factor", options.factor, { min: 0, allowInfinity: false });
|
||||||
validateNumberOption("minTimeout", options.minTimeout, { min: 0, allowInfinity: false });
|
validateNumberOption("minTimeout", options.minTimeout, { min: 0, allowInfinity: false });
|
||||||
validateNumberOption("maxTimeout", options.maxTimeout, { min: 0, allowInfinity: true });
|
validateNumberOption("maxTimeout", options.maxTimeout, { min: 0, allowInfinity: true });
|
||||||
@@ -23352,7 +23309,7 @@ async function run() {
|
|||||||
ensureNativeProxySupport();
|
ensureNativeProxySupport();
|
||||||
const clientId = getInput("client-id") || getInput("app-id");
|
const clientId = getInput("client-id") || getInput("app-id");
|
||||||
if (!clientId) {
|
if (!clientId) {
|
||||||
throw new Error("The 'client-id' (or deprecated 'app-id') input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.");
|
throw new Error("Either 'client-id' or 'app-id' input must be set");
|
||||||
}
|
}
|
||||||
const privateKey = getInput("private-key");
|
const privateKey = getInput("private-key");
|
||||||
const owner = getInput("owner");
|
const owner = getInput("owner");
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ async function run() {
|
|||||||
|
|
||||||
const clientId = core.getInput("client-id") || core.getInput("app-id");
|
const clientId = core.getInput("client-id") || core.getInput("app-id");
|
||||||
if (!clientId) {
|
if (!clientId) {
|
||||||
throw new Error("The 'client-id' (or deprecated 'app-id') input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.");
|
throw new Error("Either 'client-id' or 'app-id' input must be set");
|
||||||
}
|
}
|
||||||
const privateKey = core.getInput("private-key");
|
const privateKey = core.getInput("private-key");
|
||||||
const owner = core.getInput("owner");
|
const owner = core.getInput("owner");
|
||||||
|
|||||||
Generated
+633
-397
File diff suppressed because it is too large
Load Diff
+8
-8
@@ -2,7 +2,7 @@
|
|||||||
"name": "create-github-app-token",
|
"name": "create-github-app-token",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "3.1.1",
|
"version": "3.0.0",
|
||||||
"description": "GitHub Action for creating a GitHub App Installation Access Token",
|
"description": "GitHub Action for creating a GitHub App Installation Access Token",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.4.0"
|
"node": ">=24.4.0"
|
||||||
@@ -19,15 +19,15 @@
|
|||||||
"@actions/core": "^3.0.0",
|
"@actions/core": "^3.0.0",
|
||||||
"@octokit/auth-app": "^8.2.0",
|
"@octokit/auth-app": "^8.2.0",
|
||||||
"@octokit/request": "^10.0.8",
|
"@octokit/request": "^10.0.8",
|
||||||
"p-retry": "^8.0.0"
|
"p-retry": "^7.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@octokit/openapi": "^22.0.0",
|
"@octokit/openapi": "^21.0.0",
|
||||||
"c8": "^11.0.0",
|
"c8": "^10.1.3",
|
||||||
"esbuild": "^0.27.4",
|
"esbuild": "^0.27.3",
|
||||||
"open-cli": "^9.0.0",
|
"open-cli": "^8.0.0",
|
||||||
"undici": "^7.24.6",
|
"undici": "^7.24.1",
|
||||||
"yaml": "^2.8.3"
|
"yaml": "^2.8.2"
|
||||||
},
|
},
|
||||||
"release": {
|
"release": {
|
||||||
"branches": [
|
"branches": [
|
||||||
|
|||||||
@@ -19,22 +19,6 @@
|
|||||||
"write"
|
"write"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"artifact_metadata": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The level of permission to grant the access token to create and retrieve build artifact metadata records.",
|
|
||||||
"enum": [
|
|
||||||
"read",
|
|
||||||
"write"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"attestations": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The level of permission to create and retrieve the access token for repository attestations.",
|
|
||||||
"enum": [
|
|
||||||
"read",
|
|
||||||
"write"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"checks": {
|
"checks": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The level of permission to grant the access token for checks on code.",
|
"description": "The level of permission to grant the access token for checks on code.",
|
||||||
@@ -75,14 +59,6 @@
|
|||||||
"write"
|
"write"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"discussions": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The level of permission to grant the access token for discussions and related comments and labels.",
|
|
||||||
"enum": [
|
|
||||||
"read",
|
|
||||||
"write"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"environments": {
|
"environments": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The level of permission to grant the access token for managing repository environments.",
|
"description": "The level of permission to grant the access token for managing repository environments.",
|
||||||
@@ -99,14 +75,6 @@
|
|||||||
"write"
|
"write"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"merge_queues": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The level of permission to grant the access token to manage the merge queues for a repository.",
|
|
||||||
"enum": [
|
|
||||||
"read",
|
|
||||||
"write"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata.",
|
"description": "The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata.",
|
||||||
|
|||||||
+2
-2
@@ -32,5 +32,5 @@ node --test --test-update-snapshots tests/index.js
|
|||||||
|
|
||||||
We have tests both for the `main.js` and `post.js` scripts.
|
We have tests both for the `main.js` and `post.js` scripts.
|
||||||
|
|
||||||
- If you do not expect an error, take [main-token-permissions-set.test.js](main-token-permissions-set.test.js) as a starting point.
|
- If you do not expect an error, take [main-token-permissions-set.test.js](tests/main-token-permissions-set.test.js) as a starting point.
|
||||||
- If your test has an expected error, take [main-missing-client-and-app-id.test.js](main-missing-client-and-app-id.test.js) as a starting point.
|
- If your test has an expected error, take [main-missing-client-and-app-id.test.js](tests/main-missing-client-and-app-id.test.js) as a starting point.
|
||||||
|
|||||||
+8
-20
@@ -2,24 +2,7 @@ exports[`action-deprecated-inputs.test.js > stdout 1`] = `
|
|||||||
app-id — Use 'client-id' instead.
|
app-id — Use 'client-id' instead.
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-app-id-fallback.test.js > stdout 1`] = `
|
exports[`main-client-id.test.js > stdout 1`] = `
|
||||||
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
|
|
||||||
|
|
||||||
::set-output name=installation-id::123456
|
|
||||||
|
|
||||||
::set-output name=app-slug::github-actions
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
|
||||||
--- REQUESTS ---
|
|
||||||
GET /repos/actions/create-github-app-token/installation
|
|
||||||
POST /app/installations/123456/access_tokens
|
|
||||||
{"repositories":["create-github-app-token"]}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`main-client-id-precedence.test.js > stdout 1`] = `
|
|
||||||
Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/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
|
||||||
|
|
||||||
@@ -56,11 +39,16 @@ POST /api/v3/app/installations/123456/access_tokens
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-missing-client-and-app-id.test.js > stderr 1`] = `
|
exports[`main-missing-client-and-app-id.test.js > stderr 1`] = `
|
||||||
The 'client-id' (or deprecated 'app-id') input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.
|
Error: Either 'client-id' or 'app-id' input must be set
|
||||||
|
at run [90m(file:///home/runner/work/create-github-app-token/create-github-app-token/[39mmain.js:23:11[90m)[39m
|
||||||
|
at [90mfile:///home/runner/work/create-github-app-token/create-github-app-token/[39mmain.js:51:16
|
||||||
|
[90m at ModuleJob.run (node:internal/modules/esm/module_job:430:25)[39m
|
||||||
|
[90m at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:661:26)[39m
|
||||||
|
at async [90mfile:///home/runner/work/create-github-app-token/create-github-app-token/[39mtests/main-missing-client-and-app-id.test.js:12:30
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-missing-client-and-app-id.test.js > stdout 1`] = `
|
exports[`main-missing-client-and-app-id.test.js > stdout 1`] = `
|
||||||
::error::The 'client-id' (or deprecated 'app-id') input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.
|
::error::Either 'client-id' or 'app-id' input must be set
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-missing-owner.test.js > stderr 1`] = `
|
exports[`main-missing-owner.test.js > stderr 1`] = `
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import { DEFAULT_ENV, test } from "./main.js";
|
|
||||||
|
|
||||||
// Verify `main` falls back to `app-id` when `client-id` is not set
|
|
||||||
await test(
|
|
||||||
() => {},
|
|
||||||
{
|
|
||||||
...DEFAULT_ENV,
|
|
||||||
"INPUT_CLIENT-ID": "",
|
|
||||||
"INPUT_APP-ID": "123456",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { DEFAULT_ENV, test } from "./main.js";
|
import { DEFAULT_ENV, test } from "./main.js";
|
||||||
|
|
||||||
// Verify `client-id` takes precedence when both `client-id` and `app-id` are set
|
// Verify `main` accepts a GitHub App client ID via the `client-id` input
|
||||||
await test(
|
await test(
|
||||||
() => {},
|
() => {},
|
||||||
{
|
{
|
||||||
...DEFAULT_ENV,
|
...DEFAULT_ENV,
|
||||||
"INPUT_CLIENT-ID": "Iv1.0123456789abcdef",
|
"INPUT_CLIENT-ID": "Iv1.0123456789abcdef",
|
||||||
"INPUT_APP-ID": "123456",
|
"INPUT_APP-ID": "",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -8,12 +8,6 @@ for (const [key, value] of Object.entries({
|
|||||||
process.env[key] = value;
|
process.env[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log only the error message, not the full stack trace, because the stack
|
|
||||||
// trace contains environment-specific paths and ANSI codes that differ
|
|
||||||
// between local and CI environments.
|
|
||||||
const _error = console.error;
|
|
||||||
console.error = (err) => _error(err?.message ?? err);
|
|
||||||
|
|
||||||
// Verify `main` exits with an error when neither `client-id` nor `app-id` is set.
|
// Verify `main` exits with an error when neither `client-id` nor `app-id` is set.
|
||||||
const { default: promise } = await import("../main.js");
|
const { default: promise } = await import("../main.js");
|
||||||
await promise;
|
await promise;
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ export const DEFAULT_ENV = {
|
|||||||
// https://docs.github.com/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
|
// https://docs.github.com/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
|
||||||
"INPUT_GITHUB-API-URL": "https://api.github.com",
|
"INPUT_GITHUB-API-URL": "https://api.github.com",
|
||||||
"INPUT_SKIP-TOKEN-REVOKE": "false",
|
"INPUT_SKIP-TOKEN-REVOKE": "false",
|
||||||
"INPUT_CLIENT-ID": "Iv1.0123456789abcdef",
|
"INPUT_APP-ID": "123456",
|
||||||
// This key is invalidated. It’s from https://github.com/octokit/auth-app.js/issues/465#issuecomment-1564998327.
|
// This key is invalidated. It’s from https://github.com/octokit/auth-app.js/issues/465#issuecomment-1564998327.
|
||||||
"INPUT_PRIVATE-KEY": `-----BEGIN RSA PRIVATE KEY-----
|
"INPUT_PRIVATE-KEY": `-----BEGIN RSA PRIVATE KEY-----
|
||||||
MIIEowIBAAKCAQEA280nfuUM9w00Ib9E2rvZJ6Qu3Ua3IqR34ZlK53vn/Iobn2EL
|
MIIEowIBAAKCAQEA280nfuUM9w00Ib9E2rvZJ6Qu3Ua3IqR34ZlK53vn/Iobn2EL
|
||||||
|
|||||||
Reference in New Issue
Block a user