From 5cc811bc40176329bb642bff9e5d9e356099ad2a Mon Sep 17 00:00:00 2001 From: Parker Brown <17183625+parkerbxyz@users.noreply.github.com> Date: Thu, 3 Apr 2025 12:09:57 -0700 Subject: [PATCH] feat!: remove deprecated inputs (#213) BREAKING CHANGE: Removed deprecated inputs (`app_id`, `private_key`, `skip_token_revoke`) and made `app-id` and `private-key` required in the action configuration. --- action.yml | 16 ++-------------- lib/post.js | 7 ++----- main.js | 18 ++++-------------- package-lock.json | 4 ++-- tests/main-missing-app-id.test.js | 9 --------- tests/main-missing-private-key.test.js | 10 ---------- tests/snapshots/index.js.md | 24 +----------------------- tests/snapshots/index.js.snap | Bin 1511 -> 1349 bytes 8 files changed, 11 insertions(+), 77 deletions(-) delete mode 100644 tests/main-missing-app-id.test.js delete mode 100644 tests/main-missing-private-key.test.js diff --git a/action.yml b/action.yml index aab57bc..38b6dc7 100644 --- a/action.yml +++ b/action.yml @@ -7,18 +7,10 @@ branding: inputs: app-id: description: "GitHub App ID" - required: false # TODO: When 'app_id' is removed, make 'app-id' required - app_id: - description: "GitHub App ID" - required: false - deprecationMessage: "'app_id' is deprecated and will be removed in a future version. Use 'app-id' instead." + required: true private-key: description: "GitHub App private key" - required: false # TODO: When 'private_key' is removed, make 'private-key' required - private_key: - description: "GitHub App private key" - required: false - deprecationMessage: "'private_key' is deprecated and will be removed in a future version. Use 'private-key' instead." + required: true owner: description: "The owner of the GitHub App installation (defaults to current repository owner)" required: false @@ -28,10 +20,6 @@ inputs: skip-token-revoke: description: "If truthy, the token will not be revoked when the current job is complete" required: false - skip_token_revoke: - description: "If truthy, the token will not be revoked when the current job is complete" - required: false - deprecationMessage: "'skip_token_revoke' is deprecated and will be removed in a future version. Use 'skip-token-revoke' instead." # Make GitHub API configurable to support non-GitHub Cloud use cases # see https://github.com/actions/create-github-app-token/issues/77 github-api-url: diff --git a/lib/post.js b/lib/post.js index 9b294ae..f21174d 100644 --- a/lib/post.js +++ b/lib/post.js @@ -5,9 +5,7 @@ * @param {import("@octokit/request").request} request */ export async function post(core, request) { - const skipTokenRevoke = Boolean( - core.getInput("skip-token-revoke") || core.getInput("skip_token_revoke") - ); + const skipTokenRevoke = Boolean(core.getInput("skip-token-revoke")); if (skipTokenRevoke) { core.info("Token revocation was skipped"); @@ -35,8 +33,7 @@ export async function post(core, request) { }); core.info("Token revoked"); } catch (error) { - core.warning( - `Token revocation failed: ${error.message}`) + core.warning(`Token revocation failed: ${error.message}`); } } diff --git a/main.js b/main.js index 81b7767..ac3a7c5 100644 --- a/main.js +++ b/main.js @@ -3,9 +3,9 @@ import core from "@actions/core"; import { createAppAuth } from "@octokit/auth-app"; +import { getPermissionsFromInputs } from "./lib/get-permissions-from-inputs.js"; import { main } from "./lib/main.js"; import request from "./lib/request.js"; -import { getPermissionsFromInputs } from "./lib/get-permissions-from-inputs.js"; if (!process.env.GITHUB_REPOSITORY) { throw new Error("GITHUB_REPOSITORY missing, must be set to '/'"); @@ -15,16 +15,8 @@ if (!process.env.GITHUB_REPOSITORY_OWNER) { throw new Error("GITHUB_REPOSITORY_OWNER missing, must be set to ''"); } -const appId = core.getInput("app-id") || core.getInput("app_id"); -if (!appId) { - // The 'app_id' input was previously required, but it and 'app-id' are both optional now, until the former is removed. Still, we want to ensure that at least one of them is set. - throw new Error("Input required and not supplied: app-id"); -} -const privateKey = core.getInput("private-key") || core.getInput("private_key"); -if (!privateKey) { - // The 'private_key' input was previously required, but it and 'private-key' are both optional now, until the former is removed. Still, we want to ensure that at least one of them is set. - throw new Error("Input required and not supplied: private-key"); -} +const appId = core.getInput("app-id"); +const privateKey = core.getInput("private-key"); const owner = core.getInput("owner"); const repositories = core .getInput("repositories") @@ -32,9 +24,7 @@ const repositories = core .map((s) => s.trim()) .filter((x) => x !== ""); -const skipTokenRevoke = Boolean( - core.getInput("skip-token-revoke") || core.getInput("skip_token_revoke"), -); +const skipTokenRevoke = Boolean(core.getInput("skip-token-revoke")); const permissions = getPermissionsFromInputs(process.env); diff --git a/package-lock.json b/package-lock.json index 42a7c74..954ed1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "create-github-app-token", - "version": "1.11.6", + "version": "1.12.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "create-github-app-token", - "version": "1.11.6", + "version": "1.12.0", "license": "MIT", "dependencies": { "@actions/core": "^1.11.1", diff --git a/tests/main-missing-app-id.test.js b/tests/main-missing-app-id.test.js deleted file mode 100644 index 9382b44..0000000 --- a/tests/main-missing-app-id.test.js +++ /dev/null @@ -1,9 +0,0 @@ -process.env.GITHUB_REPOSITORY_OWNER = "actions"; -process.env.GITHUB_REPOSITORY = "actions/create-github-app-token"; - -// Verify `main` exits with an error when neither the `app-id` nor `app_id` input is set. -try { - await import("../main.js"); -} catch (error) { - console.error(error.message); -} diff --git a/tests/main-missing-private-key.test.js b/tests/main-missing-private-key.test.js deleted file mode 100644 index a78b1c7..0000000 --- a/tests/main-missing-private-key.test.js +++ /dev/null @@ -1,10 +0,0 @@ -process.env.GITHUB_REPOSITORY_OWNER = "actions"; -process.env.GITHUB_REPOSITORY = "actions/create-github-app-token"; -process.env["INPUT_APP-ID"] = "123456"; - -// Verify `main` exits with an error when neither the `private-key` nor `private_key` input is set. -try { - await import("../main.js"); -} catch (error) { - console.error(error.message); -} diff --git a/tests/snapshots/index.js.md b/tests/snapshots/index.js.md index f085f87..eeb7387 100644 --- a/tests/snapshots/index.js.md +++ b/tests/snapshots/index.js.md @@ -12,9 +12,7 @@ Generated by [AVA](https://avajs.dev). > stdout - `app_id — 'app_id' is deprecated and will be removed in a future version. Use 'app-id' instead.␊ - private_key — 'private_key' is deprecated and will be removed in a future version. Use 'private-key' instead.␊ - skip_token_revoke — 'skip_token_revoke' is deprecated and will be removed in a future version. Use 'skip-token-revoke' instead.` + '' ## main-custom-github-api-url.test.js @@ -39,16 +37,6 @@ Generated by [AVA](https://avajs.dev). POST /api/v3/app/installations/123456/access_tokens␊ {"repositories":["create-github-app-token"]}` -## main-missing-app-id.test.js - -> stderr - - 'Input required and not supplied: app-id' - -> stdout - - '' - ## main-missing-owner.test.js > stderr @@ -59,16 +47,6 @@ Generated by [AVA](https://avajs.dev). '' -## main-missing-private-key.test.js - -> stderr - - 'Input required and not supplied: private-key' - -> stdout - - '' - ## main-missing-repository.test.js > stderr diff --git a/tests/snapshots/index.js.snap b/tests/snapshots/index.js.snap index 2291b3afed0274a2edb7b728e95da7287556f135..14f1a6cf97064fb740225c1f800358562db9872b 100644 GIT binary patch literal 1349 zcmV-L1-kk{RzVx`Z)Seq z8ILEww_A>9_4seEKrrFJGeRxFJXg2D55S@VY@NA&D0oo-7sa1A<1Y1i*Ax7gSGG+B z{qBvWx0dAJ@|#QVErCN@;Iz50AqdVd;DzF}Rjp5%t6L!#USIDp(G6QV^_d<9&h^_p zTIt1$to*Rz4P6Kbb!`%W?{Ox)fB`2QM1fcVP{G^|5nc~m()NO6Ax#y4sXAX*B{d?W z+N3oiS~PZC%b6y%ZM{!<&onz-eqyYDQ-@mRUS+dlt#2BYM!jy7t&QqNwN~E(qrP#s zMsrvTmFPGuINrpiefUzfkS+vsxuA|i)vPkxG>uBN_Qm?FqOwoi2|L)}xRX(TWKlW* z9Rmrtp0KkK;F-??;9J5pD`jI{FV}U$XjUqwQ8SJ5lbo*WWWVw7QRAR_K=2~B-Dr{$ zLQxu2OKN6HV|k@HGgFFpJ@;VmU|Ju`B);XPXjCwy1)QI#`aJhsizA?!Pv=5#{9-28 zA1JQ-jB_MQSNP54`EWZ<>+;1=~U zYq>CVm}8UjA@BF*k>ZE)XjW0&vB&(ul0iC21{79*asIDYC|`q>F(f zTE@_M4~Fxd_jiKJzn1d5oQJpuQIRK>Ls_4!<{4hBO`Jzvvg-=yfLhgX=#WPRD&i?v zAOCf!P*;?52xKS8kaEIQ;9~CS*PeyanJCc^O@=)=CfiKxge|i5U^faOeZfauK!1E4 z0I^xS4GMl-AFE}wiRHOAFOq!_!AL3y;O7wgNu+s|fYT}#MzAa|MA^2qQgN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