Compare commits

...

22 Commits

Author SHA1 Message Date
semantic-release-bot 9d97a4282b build(release): 1.5.0 [skip ci]
# [1.5.0](https://github.com/actions/create-github-app-token/compare/v1.4.0...v1.5.0) (2023-10-06)

### Features

* use dash notation for inputs (deprecates underscore notation) ([#59](https://github.com/actions/create-github-app-token/issues/59)) ([7b1d2ae](https://github.com/actions/create-github-app-token/commit/7b1d2aef87b41884c03f2e69a0a422d5c69c5d72)), closes [#57](https://github.com/actions/create-github-app-token/issues/57) [/github.com/actions/create-github-app-token/issues/57#issuecomment-1751272252](https://github.com//github.com/actions/create-github-app-token/issues/57/issues/issuecomment-1751272252)
2023-10-06 20:42:48 +00:00
Gregor Martynus d21ec768fd ci(release): do not persist credentials when checking out (#62) 2023-10-06 13:42:08 -07:00
Gregor Martynus 998b8757ce ci(release): use local version (#60)
follow up to
https://github.com/actions/create-github-app-token/pull/59#issuecomment-1751353971

---------

Co-authored-by: Parker Brown <17183625+parkerbxyz@users.noreply.github.com>
2023-10-06 13:29:38 -07:00
Parker Brown b94a200224 docs: update skip-token-revoke input name (#61)
This is a quick follow-up to #59. I was mid-review when it merged and
noticed one instance of `skip_token_revoke` in the README that didn't
get changed to `skip-token-revoke`. The PR merged just before I pushed a
commit to fix it.
2023-10-06 13:19:45 -07:00
Clay Miller 7b1d2aef87 feat: use dash notation for inputs (deprecates underscore notation) (#59)
Fixes #57 

This PR implements the 3-step plan proposed by @gr2m in
https://github.com/actions/create-github-app-token/issues/57#issuecomment-1751272252:

> 1. Support both input types
> 2. Log a deprecation warning for the old notation
> 3. Add a test for deprecations

Although this PR supports both input formats simultaneously, I opted
_not_ to document the old format in the updated README. That’s a
decision I’m happy to revisit, if y’all would prefer to have
documentation for both the old and new formats.
2023-10-06 13:10:49 -07:00
Gregor Martynus bdb2377ad0 test: add coverage (#58) 2023-10-06 12:54:48 -07:00
Clay Miller 9b283559f1 test: integration tests for main.js (#56)
Part of https://github.com/actions/create-github-app-token/issues/43

This PR adds tests for
[`main.js`](https://github.com/actions/create-github-app-token/blob/main/lib/main.js),
similar to [the tests that already exist for
`post.js`](https://github.com/actions/create-github-app-token/tree/main/tests).

Specifically, it tests that:
- `main` exits with an error when `GITHUB_REPOSITORY` is missing.
- `main` exits with an error when `GITHUB_REPOSITORY_OWNER` is missing.
- `main` successfully obtains a token when…
- …the `owner` and `repositories` inputs are set (and the latter is a
single repo).
- …the `owner` and `repositories` inputs are set (and the latter is a
list of repos).
- …the `owner` input is set (to an org), but the `repositories` input
isn’t set.
- …the `owner` input is set (to a user), but the `repositories` input
isn’t set.
  - …the `owner` input is not set, but the `repositories` input is set.
  - …neither the `owner` nor `repositories` input is set.

❧

Architecturally, in order to keep individual tests concise, this PR adds
`tests/main.js`, which:
- sets commonly-used inputs, environment variables, and mocks, then
- calls a callback function that can edit the variables and add
additional mocks, then
- runs `main.js` itself.

The `tests/main-token-get-*.test.js` test files run `tests/main.js` with
various scenario-specific callback functions.
2023-10-06 12:39:35 -07:00
semantic-release-bot 8210939678 build(release): 1.4.0 [skip ci]
# [1.4.0](https://github.com/actions/create-github-app-token/compare/v1.3.0...v1.4.0) (2023-10-06)

### Features

* Add a `skip_token_revoke` input for configuring token revocation ([#54](https://github.com/actions/create-github-app-token/issues/54)) ([9ec88c4](https://github.com/actions/create-github-app-token/commit/9ec88c41eef7052418d233d147c59fbdce19c56f)), closes [1#L46-L47](https://github.com/1/issues/L46-L47) [1#L132](https://github.com/1/issues/L132)
2023-10-06 16:11:28 +00:00
Clay Miller 9ec88c41ee feat: Add a skip_token_revoke input for configuring token revocation (#54)
Fixes https://github.com/actions/create-github-app-token/issues/55

Currently, `actions/create-github-app-token` always/unconditionally
revokes the installation access token in a `post` step, at the
completion of the current job. This prevents tokens from being used in
other jobs.

This PR makes this behavior configurable:
- When the `skip-token-revoke` input is not specified (i.e. by default),
the token is revoked in a `post` step (i.e. the current behavior).
- When the `skip-token-revoke` input is set to a truthy value (e.g.
`"true"`[^1]), the token is not revoked in a `post` step.

This PR adds a test for the `skip-token-revoke: "true"` case.

This is configurable in other app token actions, e.g.
[tibdex/github-app-token](https://github.com/tibdex/github-app-token/blob/3eb77c7243b85c65e84acfa93fdbac02fb6bd532/README.md?plain=1#L46-L47)
and
[wow-actions/use-app-token](https://github.com/wow-actions/use-app-token/blob/cd772994fc762f99cf291f308797341327a49b0c/README.md?plain=1#L132).

[^1]: Note that `"false"` is also truthy: `Boolean("false")` is `true`.
If we think that’ll potentially confuse folks, I can require
`skip-token-revoke` to be set explicitly to `"true"`.
2023-10-06 09:10:49 -07:00
semantic-release-bot d400084c45 build(release): 1.3.0 [skip ci]
# [1.3.0](https://github.com/actions/create-github-app-token/compare/v1.2.2...v1.3.0) (2023-10-04)

### Features

* support tokens scoped to multiple repositories within organization ([#46](https://github.com/actions/create-github-app-token/issues/46)) ([20fd863](https://github.com/actions/create-github-app-token/commit/20fd86373fdcbeffde8b73b17ebb3a7a62c6c407))
2023-10-04 05:29:18 +00:00
Tim Reimherr 20fd86373f feat: support tokens scoped to multiple repositories within organization (#46)
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
Co-authored-by: Parker Brown <17183625+parkerbxyz@users.noreply.github.com>
2023-10-03 22:28:48 -07:00
semantic-release-bot 5804f049e1 build(release): 1.2.2 [skip ci]
## [1.2.2](https://github.com/actions/create-github-app-token/compare/v1.2.1...v1.2.2) (2023-10-02)

### Bug Fixes

* **deps:** bump the production-dependencies group with 3 updates ([#51](https://github.com/actions/create-github-app-token/issues/51)) ([6d98b25](https://github.com/actions/create-github-app-token/commit/6d98b259d9c6bef17db279eb4aefbbd031400ba4)), closes [#1511](https://github.com/actions/create-github-app-token/issues/1511) [#535](https://github.com/actions/create-github-app-token/issues/535) [#535](https://github.com/actions/create-github-app-token/issues/535) [#533](https://github.com/actions/create-github-app-token/issues/533) [#531](https://github.com/actions/create-github-app-token/issues/531) [#530](https://github.com/actions/create-github-app-token/issues/530) [#524](https://github.com/actions/create-github-app-token/issues/524) [#637](https://github.com/actions/create-github-app-token/issues/637) [#637](https://github.com/actions/create-github-app-token/issues/637) [#631](https://github.com/actions/create-github-app-token/issues/631) [#626](https://github.com/actions/create-github-app-token/issues/626)
2023-10-02 04:28:50 +00:00
dependabot[bot] 84daa2c0f0 build(deps-dev): bump the development-dependencies group with 2 updates (#52)
Bumps the development-dependencies group with 2 updates:
[esbuild](https://github.com/evanw/esbuild) and
[undici](https://github.com/nodejs/undici).

Updates `esbuild` from 0.19.2 to 0.19.4
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/evanw/esbuild/releases">esbuild's
releases</a>.</em></p>
<blockquote>
<h2>v0.19.4</h2>
<ul>
<li>
<p>Fix printing of JavaScript decorators in tricky cases (<a
href="https://redirect.github.com/evanw/esbuild/issues/3396">#3396</a>)</p>
<p>This release fixes some bugs where esbuild's pretty-printing of
JavaScript decorators could incorrectly produced code with a syntax
error. The problem happened because esbuild sometimes substitutes
identifiers for other expressions in the pretty-printer itself, but the
decision about whether to wrap the expression or not didn't account for
this. Here are some examples:</p>
<pre lang="js"><code>// Original code
import { constant } from './constants.js'
import { imported } from 'external'
import { undef } from './empty.js'
class Foo {
  @constant()
  @imported()
  @undef()
  foo
}
<p>// Old output (with --bundle --format=cjs --packages=external
--minify-syntax)
var import_external = require(&quot;external&quot;);
var Foo = class {
<a href="https://github.com/123"><code>@​123</code></a>()
@(0, import_external.imported)()
@(void 0)()
foo;
};</p>
<p>// New output (with --bundle --format=cjs --packages=external
--minify-syntax)
var import_external = require(&quot;external&quot;);
var Foo = class {
@(123())
@((0, import_external.imported)())
@((void 0)())
foo;
};
</code></pre></p>
</li>
<li>
<p>Allow pre-release versions to be passed to <code>target</code> (<a
href="https://redirect.github.com/evanw/esbuild/issues/3388">#3388</a>)</p>
<p>People want to be able to pass version numbers for unreleased
versions of node (which have extra stuff after the version numbers) to
esbuild's <code>target</code> setting and have esbuild do something
reasonable with them. These version strings are of course not present in
esbuild's internal feature compatibility table because an unreleased
version has not been released yet (by definition). With this release,
esbuild will now attempt to accept these version strings passed to
<code>target</code> and do something reasonable with them.</p>
</li>
</ul>
<h2>v0.19.3</h2>
<ul>
<li>
<p>Fix <code>list-style-type</code> with the <code>local-css</code>
loader (<a
href="https://redirect.github.com/evanw/esbuild/issues/3325">#3325</a>)</p>
<p>The <code>local-css</code> loader incorrectly treated all identifiers
provided to <code>list-style-type</code> as a custom local identifier.
That included identifiers such as <code>none</code> which have special
meaning in CSS, and which should not be treated as custom local
identifiers. This release fixes this bug:</p>
<pre lang="css"><code>/* Original code */
ul { list-style-type: none }
<p>/* Old output (with --loader=local-css) */
</code></pre></p>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/evanw/esbuild/blob/main/CHANGELOG.md">esbuild's
changelog</a>.</em></p>
<blockquote>
<h2>0.19.4</h2>
<ul>
<li>
<p>Fix printing of JavaScript decorators in tricky cases (<a
href="https://redirect.github.com/evanw/esbuild/issues/3396">#3396</a>)</p>
<p>This release fixes some bugs where esbuild's pretty-printing of
JavaScript decorators could incorrectly produced code with a syntax
error. The problem happened because esbuild sometimes substitutes
identifiers for other expressions in the pretty-printer itself, but the
decision about whether to wrap the expression or not didn't account for
this. Here are some examples:</p>
<pre lang="js"><code>// Original code
import { constant } from './constants.js'
import { imported } from 'external'
import { undef } from './empty.js'
class Foo {
  @constant()
  @imported()
  @undef()
  foo
}
<p>// Old output (with --bundle --format=cjs --packages=external
--minify-syntax)
var import_external = require(&quot;external&quot;);
var Foo = class {
<a href="https://github.com/123"><code>@​123</code></a>()
@(0, import_external.imported)()
@(void 0)()
foo;
};</p>
<p>// New output (with --bundle --format=cjs --packages=external
--minify-syntax)
var import_external = require(&quot;external&quot;);
var Foo = class {
@(123())
@((0, import_external.imported)())
@((void 0)())
foo;
};
</code></pre></p>
</li>
<li>
<p>Allow pre-release versions to be passed to <code>target</code> (<a
href="https://redirect.github.com/evanw/esbuild/issues/3388">#3388</a>)</p>
<p>People want to be able to pass version numbers for unreleased
versions of node (which have extra stuff after the version numbers) to
esbuild's <code>target</code> setting and have esbuild do something
reasonable with them. These version strings are of course not present in
esbuild's internal feature compatibility table because an unreleased
version has not been released yet (by definition). With this release,
esbuild will now attempt to accept these version strings passed to
<code>target</code> and do something reasonable with them.</p>
</li>
</ul>
<h2>0.19.3</h2>
<ul>
<li>
<p>Fix <code>list-style-type</code> with the <code>local-css</code>
loader (<a
href="https://redirect.github.com/evanw/esbuild/issues/3325">#3325</a>)</p>
<p>The <code>local-css</code> loader incorrectly treated all identifiers
provided to <code>list-style-type</code> as a custom local identifier.
That included identifiers such as <code>none</code> which have special
meaning in CSS, and which should not be treated as custom local
identifiers. This release fixes this bug:</p>
<pre lang="css"><code>/* Original code */
ul { list-style-type: none }
</code></pre>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/evanw/esbuild/commit/a75b16ec09e76a050cea8ad43588172dc297784d"><code>a75b16e</code></a>
publish 0.19.4 to npm</li>
<li><a
href="https://github.com/evanw/esbuild/commit/65a4439ff7c469ffc654f497fe3dee6bb1fa2ddb"><code>65a4439</code></a>
fix <a
href="https://redirect.github.com/evanw/esbuild/issues/3396">#3396</a>:
js decorator pretty-printing bugs</li>
<li><a
href="https://github.com/evanw/esbuild/commit/6ad177c55bb5ea6f47cf741487308ee612c75222"><code>6ad177c</code></a>
add some js decorator printing tests</li>
<li><a
href="https://github.com/evanw/esbuild/commit/0e1696fdce7cd97d2d500358b69a4051f1417585"><code>0e1696f</code></a>
ignore <code>TP</code> in data from caniuse-lite</li>
<li><a
href="https://github.com/evanw/esbuild/commit/e7bf735c440c3e7ecc1b59826071ff6891f1691f"><code>e7bf735</code></a>
fix <a
href="https://redirect.github.com/evanw/esbuild/issues/3390">#3390</a>:
allow <code>using</code> disposable functions (<a
href="https://redirect.github.com/evanw/esbuild/issues/3391">#3391</a>)</li>
<li><a
href="https://github.com/evanw/esbuild/commit/24bea0e759553755f73583c4d79c40d8a8bbf975"><code>24bea0e</code></a>
update <code>compat-table</code> (note: regexp unicode 15.1)</li>
<li><a
href="https://github.com/evanw/esbuild/commit/ea9c644db3c95cd264fa12f6d85fd67daabb51eb"><code>ea9c644</code></a>
fix <a
href="https://redirect.github.com/evanw/esbuild/issues/3388">#3388</a>:
do something with pre-release versions</li>
<li><a
href="https://github.com/evanw/esbuild/commit/673ad10ff752486aa90749b63ebeb952c29106a1"><code>673ad10</code></a>
publish 0.19.3 to npm</li>
<li><a
href="https://github.com/evanw/esbuild/commit/6402f110e30d034d19a5f0410d3f5c6fdf86900b"><code>6402f11</code></a>
basic support for parsing import attributes</li>
<li><a
href="https://github.com/evanw/esbuild/commit/7ece5567511b25fa559082a8fd9aef8c23db66a1"><code>7ece556</code></a>
fix <a
href="https://redirect.github.com/evanw/esbuild/issues/3322">#3322</a>:
avoid temporaries before <code>&quot;use strict&quot;</code></li>
<li>Additional commits viewable in <a
href="https://github.com/evanw/esbuild/compare/v0.19.2...v0.19.4">compare
view</a></li>
</ul>
</details>
<br />

Updates `undici` from 5.23.0 to 5.25.2
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/nodejs/undici/releases">undici's
releases</a>.</em></p>
<blockquote>
<h2>v5.25.2</h2>
<h2>What's Changed</h2>
<ul>
<li>Add Khaf to releasers by <a
href="https://github.com/mcollina"><code>@​mcollina</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2276">nodejs/undici#2276</a></li>
<li>fix: fix request with readable mode is object by <a
href="https://github.com/killagu"><code>@​killagu</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2279">nodejs/undici#2279</a></li>
<li>fix loading websockets when node is built w/ --without-ssl by <a
href="https://github.com/KhafraDev"><code>@​KhafraDev</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2282">nodejs/undici#2282</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/killagu"><code>@​killagu</code></a> made
their first contribution in <a
href="https://redirect.github.com/nodejs/undici/pull/2279">nodejs/undici#2279</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/nodejs/undici/compare/v5.25.1...v5.25.2">https://github.com/nodejs/undici/compare/v5.25.1...v5.25.2</a></p>
<h2>v5.25.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Add publish types script by <a
href="https://github.com/Ethan-Arrowood"><code>@​Ethan-Arrowood</code></a>
in <a
href="https://redirect.github.com/nodejs/undici/pull/2273">nodejs/undici#2273</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/nodejs/undici/compare/v5.25.0...v5.25.1">https://github.com/nodejs/undici/compare/v5.25.0...v5.25.1</a></p>
<h2>v5.25.0</h2>
<h2>What's Changed</h2>
<ul>
<li>fix: h2 without body by <a
href="https://github.com/metcoder95"><code>@​metcoder95</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2258">nodejs/undici#2258</a></li>
<li>ci: remove duplicated runs by <a
href="https://github.com/metcoder95"><code>@​metcoder95</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2265">nodejs/undici#2265</a></li>
<li>improve documentation of timeouts by making the units clear in all
places by <a href="https://github.com/mcfedr"><code>@​mcfedr</code></a>
in <a
href="https://redirect.github.com/nodejs/undici/pull/2266">nodejs/undici#2266</a></li>
<li>expose websocket in node bundle by <a
href="https://github.com/KhafraDev"><code>@​KhafraDev</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2217">nodejs/undici#2217</a></li>
<li>test: fix Fetch/HTTP2 tests by <a
href="https://github.com/metcoder95"><code>@​metcoder95</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2263">nodejs/undici#2263</a></li>
<li>fix undici when node is built with --without-ssl by <a
href="https://github.com/KhafraDev"><code>@​KhafraDev</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2272">nodejs/undici#2272</a></li>
<li>fix: Fix type definition for Client Interceptors by <a
href="https://github.com/ComradeCow"><code>@​ComradeCow</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2269">nodejs/undici#2269</a></li>
<li>Fix http2 agent by <a
href="https://github.com/mcollina"><code>@​mcollina</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2275">nodejs/undici#2275</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/ComradeCow"><code>@​ComradeCow</code></a> made
their first contribution in <a
href="https://redirect.github.com/nodejs/undici/pull/2269">nodejs/undici#2269</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/nodejs/undici/compare/v5.24.0...v5.25.0">https://github.com/nodejs/undici/compare/v5.24.0...v5.25.0</a></p>
<h2>v5.24.0</h2>
<h2>Notable Changes</h2>
<ul>
<li>feat: Add H2 support by <a
href="https://github.com/metcoder95"><code>@​metcoder95</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2061">nodejs/undici#2061</a></li>
</ul>
<h2>What's Changed</h2>
<ul>
<li>build(deps): bump step-security/harden-runner from 2.4.1 to 2.5.0 by
<a href="https://github.com/dependabot"><code>@​dependabot</code></a> in
<a
href="https://redirect.github.com/nodejs/undici/pull/2203">nodejs/undici#2203</a></li>
<li>better stack trace for body.json by <a
href="https://github.com/KhafraDev"><code>@​KhafraDev</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2215">nodejs/undici#2215</a></li>
<li>allow http &amp; https websocket urls by <a
href="https://github.com/KhafraDev"><code>@​KhafraDev</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2218">nodejs/undici#2218</a></li>
<li>build(deps-dev): bump <code>@​sinonjs/fake-timers</code> from 10.3.0
to 11.1.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2221">nodejs/undici#2221</a></li>
<li>fix: pass ProxyAgent proxy status code error by <a
href="https://github.com/NBNGaming"><code>@​NBNGaming</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2162">nodejs/undici#2162</a></li>
<li>fix failing test by <a
href="https://github.com/KhafraDev"><code>@​KhafraDev</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2223">nodejs/undici#2223</a></li>
<li>docs: update MockPool.md intercept method description by <a
href="https://github.com/capaj"><code>@​capaj</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2220">nodejs/undici#2220</a></li>
<li>Update wpts by <a
href="https://github.com/KhafraDev"><code>@​KhafraDev</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2226">nodejs/undici#2226</a></li>
<li>build(deps): bump github/codeql-action from 2.21.2 to 2.21.5 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2240">nodejs/undici#2240</a></li>
<li>build(deps): bump actions/setup-node from 3.6.0 to 3.8.1 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nodejs/undici/pull/2237">nodejs/undici#2237</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/nodejs/undici/commit/4013c4b8932e73728809e4106d5c9d9d40648031"><code>4013c4b</code></a>
Bumped v5.25.2</li>
<li><a
href="https://github.com/nodejs/undici/commit/b85ac789de76d95de6db7d442b31feed46c671ca"><code>b85ac78</code></a>
fix loading websockets when node is built w/ --without-ssl (<a
href="https://redirect.github.com/nodejs/undici/issues/2282">#2282</a>)</li>
<li><a
href="https://github.com/nodejs/undici/commit/ba95ff6cf622a4ce8d6d9d42da22ebf9f15685a0"><code>ba95ff6</code></a>
fix: fix request with readable mode is object (<a
href="https://redirect.github.com/nodejs/undici/issues/2279">#2279</a>)</li>
<li><a
href="https://github.com/nodejs/undici/commit/a73260339fec7852b1c9a067b342bad0b87b20ee"><code>a732603</code></a>
Add Khaf to releasers (<a
href="https://redirect.github.com/nodejs/undici/issues/2276">#2276</a>)</li>
<li><a
href="https://github.com/nodejs/undici/commit/c86279c9bcf62fe28d124b124b91eb364d478a25"><code>c86279c</code></a>
undici-types@5.25.1</li>
<li><a
href="https://github.com/nodejs/undici/commit/e8a667452cb00bf46a3bb62ee0d5af61723fb62a"><code>e8a6674</code></a>
5.25.1</li>
<li><a
href="https://github.com/nodejs/undici/commit/5c2e597bd938ce99a0246f9dfbfac6d3f3a31be9"><code>5c2e597</code></a>
Add publish types script (<a
href="https://redirect.github.com/nodejs/undici/issues/2273">#2273</a>)</li>
<li><a
href="https://github.com/nodejs/undici/commit/985b3816708512bafefa1544def183cc6d1536be"><code>985b381</code></a>
Bumped v5.25.0</li>
<li><a
href="https://github.com/nodejs/undici/commit/d1e867e1cddbfed6ee405c8d8872ed4f0c964689"><code>d1e867e</code></a>
Fix http2 agent (<a
href="https://redirect.github.com/nodejs/undici/issues/2275">#2275</a>)</li>
<li><a
href="https://github.com/nodejs/undici/commit/4d7c319d67a73f7284216ac38e81be4f94f70cde"><code>4d7c319</code></a>
Fix type definition for Client Interceptors (<a
href="https://redirect.github.com/nodejs/undici/issues/2269">#2269</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/nodejs/undici/compare/v5.23.0...v5.25.2">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-01 21:28:18 -07:00
dependabot[bot] 6d98b259d9 fix(deps): bump the production-dependencies group with 3 updates (#51)
Bumps the production-dependencies group with 3 updates:
[@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core),
[@octokit/auth-app](https://github.com/octokit/auth-app.js) and
[@octokit/request](https://github.com/octokit/request.js).

Updates `@actions/core` from 1.10.0 to 1.10.1
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md"><code>@​actions/core</code>'s
changelog</a>.</em></p>
<blockquote>
<h3>1.10.1</h3>
<ul>
<li>Fix error message reference in oidc utils <a
href="https://redirect.github.com/actions/toolkit/pull/1511">#1511</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/actions/toolkit/commits/HEAD/packages/core">compare
view</a></li>
</ul>
</details>
<br />

Updates `@octokit/auth-app` from 6.0.0 to 6.0.1
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/octokit/auth-app.js/releases"><code>@​octokit/auth-app</code>'s
releases</a>.</em></p>
<blockquote>
<h2>v6.0.1</h2>
<h2><a
href="https://github.com/octokit/auth-app.js/compare/v6.0.0...v6.0.1">6.0.1</a>
(2023-09-23)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deps:</strong> update dependency
<code>@​octokit/types</code> to v12 (<a
href="https://redirect.github.com/octokit/auth-app.js/issues/535">#535</a>)
(<a
href="https://github.com/octokit/auth-app.js/commit/d7157719c2d28f9ffdfada61139b0d4984723a65">d715771</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/octokit/auth-app.js/commit/d7157719c2d28f9ffdfada61139b0d4984723a65"><code>d715771</code></a>
fix(deps): update dependency <code>@​octokit/types</code> to v12 (<a
href="https://redirect.github.com/octokit/auth-app.js/issues/535">#535</a>)</li>
<li><a
href="https://github.com/octokit/auth-app.js/commit/62cfc5bbce931e056852e91bdc3d479e3e399881"><code>62cfc5b</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
46da6c0</li>
<li><a
href="https://github.com/octokit/auth-app.js/commit/b1c796928a8d59af23749d06e1f75e5d047b28f8"><code>b1c7969</code></a>
build(deps): lock file maintenance (<a
href="https://redirect.github.com/octokit/auth-app.js/issues/533">#533</a>)</li>
<li><a
href="https://github.com/octokit/auth-app.js/commit/f584646566c0de02e85cecf40015a44f15b22028"><code>f584646</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
1f6c514</li>
<li><a
href="https://github.com/octokit/auth-app.js/commit/414bea3cc3bab71bc0148747678bddb0a4c6b9f9"><code>414bea3</code></a>
build(deps): lock file maintenance (<a
href="https://redirect.github.com/octokit/auth-app.js/issues/531">#531</a>)</li>
<li><a
href="https://github.com/octokit/auth-app.js/commit/47e4bd1660c3faed2690ade1086ef96657e0b88a"><code>47e4bd1</code></a>
build(deps): lock file maintenance (<a
href="https://redirect.github.com/octokit/auth-app.js/issues/530">#530</a>)</li>
<li><a
href="https://github.com/octokit/auth-app.js/commit/5d3973e9355ba5fb8c1c65f5710722a58d75dfbc"><code>5d3973e</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
223779b</li>
<li><a
href="https://github.com/octokit/auth-app.js/commit/192bd894e4e2a71faf2e5996eb7287deb1ad7fdc"><code>192bd89</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
46846e5</li>
<li><a
href="https://github.com/octokit/auth-app.js/commit/77cb45b6542ca1dd5d0086864e28fea0ddbe9297"><code>77cb45b</code></a>
ci(action): update actions/checkout action to v4</li>
<li><a
href="https://github.com/octokit/auth-app.js/commit/1c0d530c6b85890853b860b16f0c11e106bb676f"><code>1c0d530</code></a>
build(deps): lock file maintenance (<a
href="https://redirect.github.com/octokit/auth-app.js/issues/524">#524</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/octokit/auth-app.js/compare/v6.0.0...v6.0.1">compare
view</a></li>
</ul>
</details>
<br />

Updates `@octokit/request` from 8.1.1 to 8.1.2
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/octokit/request.js/releases"><code>@​octokit/request</code>'s
releases</a>.</em></p>
<blockquote>
<h2>v8.1.2</h2>
<h2><a
href="https://github.com/octokit/request.js/compare/v8.1.1...v8.1.2">8.1.2</a>
(2023-09-23)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deps:</strong> update dependency
<code>@​octokit/types</code> to v12 (<a
href="https://redirect.github.com/octokit/request.js/issues/637">#637</a>)
(<a
href="https://github.com/octokit/request.js/commit/8fa4d612ad80bdf4c4c7da0efd0d6ad47bb6978b">8fa4d61</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/octokit/request.js/commit/8fa4d612ad80bdf4c4c7da0efd0d6ad47bb6978b"><code>8fa4d61</code></a>
fix(deps): update dependency <code>@​octokit/types</code> to v12 (<a
href="https://redirect.github.com/octokit/request.js/issues/637">#637</a>)</li>
<li><a
href="https://github.com/octokit/request.js/commit/b4b18153458cdbeae099dcc072cac88d8e2a81c5"><code>b4b1815</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
46da6c0</li>
<li><a
href="https://github.com/octokit/request.js/commit/77683b9dd783675622720e44d6e281d95eb86ab3"><code>77683b9</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
1f6c514</li>
<li><a
href="https://github.com/octokit/request.js/commit/45f319bac6c1281e42e989f4b97cf45cf8e4cd40"><code>45f319b</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
223779b</li>
<li><a
href="https://github.com/octokit/request.js/commit/d0a545f389d55a6677bd2ad4084fca7958ba9ade"><code>d0a545f</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
46846e5 (<a
href="https://redirect.github.com/octokit/request.js/issues/631">#631</a>)</li>
<li><a
href="https://github.com/octokit/request.js/commit/1ba853ad70ba0c8e856f89628aa1df0e26aadc75"><code>1ba853a</code></a>
ci(action): update actions/checkout action to v4</li>
<li><a
href="https://github.com/octokit/request.js/commit/5f5c4bf1d7acb9670c5347051afb62f9453e7121"><code>5f5c4bf</code></a>
chore(deps): update dependency prettier to v3.0.3</li>
<li><a
href="https://github.com/octokit/request.js/commit/f964d3d249698d6fd656dd978876c8d84e20c09c"><code>f964d3d</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
94ff342</li>
<li><a
href="https://github.com/octokit/request.js/commit/29edb28325de3a60442e15c7d45f20be9c4d350d"><code>29edb28</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
8c21c80</li>
<li><a
href="https://github.com/octokit/request.js/commit/05eb0a9ab60922ea7b283082afb89798c4eb6108"><code>05eb0a9</code></a>
ci(action): update peter-evans/create-or-update-comment digest to
bb291f6 (<a
href="https://redirect.github.com/octokit/request.js/issues/626">#626</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/octokit/request.js/compare/v8.1.1...v8.1.2">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-01 21:28:07 -07:00
dependabot[bot] 3629f23f43 build(deps): bump actions/checkout from 3 to 4 (#53) 2023-10-01 21:27:42 -07:00
Gregor Martynus 4bb2d37925 ci(test): do not run end-to-end tests in PRs from forks (#48) 2023-09-21 16:34:10 -07:00
Gregor Martynus 9f83520638 ci(test): actually run integrration tests (#47) 2023-09-21 13:53:30 -07:00
Parker Brown 10f155294b test: integration tests (#40)
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
2023-09-05 08:32:55 -07:00
semantic-release-bot 49ce228ea7 build(release): 1.2.1 [skip ci]
## [1.2.1](https://github.com/actions/create-github-app-token/compare/v1.2.0...v1.2.1) (2023-08-30)

### Bug Fixes

* **GHES:** respect `GITHUB_API_URL` when creating installation access token ([#38](https://github.com/actions/create-github-app-token/issues/38)) ([c08c5ac](https://github.com/actions/create-github-app-token/commit/c08c5ace340664df431bf7f11d51b61d92358c2b)), closes [#36](https://github.com/actions/create-github-app-token/issues/36)
2023-08-30 05:30:14 +00:00
Gregor Martynus c08c5ace34 fix(GHES): respect GITHUB_API_URL when creating installation access token (#38)
Follow up to #36. I just wanted to do some refactoring but turns out I
missed to pass the custom `request` instance to `createAppAuth`. It will
fallback to the default `request` which does not respect
`GITHUB_API_URL`
2023-08-29 22:29:41 -07:00
semantic-release-bot c72844caa4 build(release): 1.2.0 [skip ci]
# [1.2.0](https://github.com/actions/create-github-app-token/compare/v1.1.5...v1.2.0) (2023-08-29)

### Features

* add GitHub Enterprise Server (GHES) support ([#36](https://github.com/actions/create-github-app-token/issues/36)) ([ede6c15](https://github.com/actions/create-github-app-token/commit/ede6c158812854da7c63aa6635138d168de14bea))
2023-08-29 23:14:09 +00:00
7Hazard ede6c15881 feat: add GitHub Enterprise Server (GHES) support (#36)
This adds support for this action to be used in GitHub Enterprise
Server.

It sends request to the base url extracted from
[GITHUB_API_URL](https://docs.github.com/en/enterprise-server@3.10/actions/learn-github-actions/variables#default-environment-variables).

---------

Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
2023-08-29 16:13:34 -07:00
33 changed files with 5367 additions and 5907 deletions
+14 -7
View File
@@ -14,16 +14,23 @@ jobs:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
# build local version to create token
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
- run: npm ci
- run: npm run build
- uses: ./
id: app-token
with:
app_id: ${{ vars.RELEASER_APP_ID }}
private_key: ${{ secrets.RELEASER_APP_PRIVATE_KEY }}
- uses: actions/checkout@v3
with:
token: ${{ steps.app-token.outputs.token }}
app-id: ${{ vars.RELEASER_APP_ID }}
private-key: ${{ secrets.RELEASER_APP_PRIVATE_KEY }}
# install release dependencies and release
- run: npm install --no-save @semantic-release/git semantic-release-plugin-github-breaking-version-tag
- run: npm run build
- run: npx semantic-release --debug
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
+23 -5
View File
@@ -1,5 +1,8 @@
name: test
on:
push:
branches:
- main
pull_request:
concurrency:
@@ -7,21 +10,36 @@ concurrency:
cancel-in-progress: true
jobs:
test:
integration:
name: Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "16.16"
node-version: 20
cache: "npm"
- run: npm ci
- run: npm test
end-to-end:
name: End-to-End
runs-on: ubuntu-latest
# do not run from forks, as forks dont have access to repository secrets
if: github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
- run: npm ci
- run: npm run build
- uses: ./ # Uses the action in the root directory
id: test
with:
app_id: ${{ vars.TEST_APP_ID }}
private_key: ${{ secrets.TEST_APP_PRIVATE_KEY }}
app-id: ${{ vars.TEST_APP_ID }}
private-key: ${{ secrets.TEST_APP_PRIVATE_KEY }}
- uses: octokit/request-action@v2.x
id: get-repository
env:
+2 -1
View File
@@ -1,2 +1,3 @@
node_modules/
.env
coverage
node_modules/
+91 -9
View File
@@ -10,7 +10,7 @@ In order to use this action, you need to:
2. [Store the App's ID in your repository environment variables](https://docs.github.com/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows) (example: `APP_ID`)
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`)
### Minimal usage
### Create a token for the current repository
```yaml
on: [issues]
@@ -22,8 +22,8 @@ jobs:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app_id: ${{ vars.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ steps.app-token.outputs.token }}
@@ -44,8 +44,8 @@ jobs:
id: app-token
with:
# required
app_id: ${{ vars.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- uses: actions/checkout@v3
with:
token: ${{ steps.app-token.outputs.token }}
@@ -57,16 +57,98 @@ jobs:
github_token: ${{ steps.app-token.outputs.token }}
```
### Create a token for all repositories in the current owner's installation
```yaml
on: [workflow_dispatch]
jobs:
hello-world:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ steps.app-token.outputs.token }}
issue-number: ${{ github.event.issue.number }}
body: "Hello, World!"
```
### Create a token for multiple repositories in the current owner's installation
```yaml
on: [issues]
jobs:
hello-world:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: "repo1,repo2"
- uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ steps.app-token.outputs.token }}
issue-number: ${{ github.event.issue.number }}
body: "Hello, World!"
```
### Create a token for all repositories in another owner's installation
```yaml
on: [issues]
jobs:
hello-world:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
owner: another-owner
- uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ steps.app-token.outputs.token }}
issue-number: ${{ github.event.issue.number }}
body: "Hello, World!"
```
## Inputs
### `app_id`
### `app-id`
**Required:** GitHub App ID.
### `private_key`
### `private-key`
**Required:** GitHub App private key.
### `owner`
**Optional:** GitHub App installation owner. If empty, defaults to the current repository owner.
### `repositories`
**Optional:** Comma-separated list of repositories to grant access to.
> [!NOTE]
> If `owner` is set and `repositories` is empty, access will be scoped to all repositories in the provided repository owner's installation. If `owner` and `repositories` are empty, access will be scoped to only the current repository.
### `skip-token-revoke`
**Optional:** If truthy, the token will not be revoked when the current job is complete.
## Outputs
### `token`
@@ -77,10 +159,10 @@ GitHub App installation access token.
The action creates an installation access token using [the `POST /app/installations/{installation_id}/access_tokens` endpoint](https://docs.github.com/rest/apps/apps?apiVersion=2022-11-28#create-an-installation-access-token-for-an-app). By default,
1. The token is scoped to the current repository.
1. The token is scoped to the current repository or `repositories` if set.
2. The token inherits all the installation's permissions.
3. The token is set as output `token` which can be used in subsequent steps.
4. The token is revoked in the `post` step of the action, which means it cannot be passed to another job.
4. Unless the `skip-token-revoke` input is set to a truthy value, the token is revoked in the `post` step of the action, which means it cannot be passed to another job.
5. The token is masked, it cannot be logged accidentally.
> [!NOTE]
+23 -2
View File
@@ -5,12 +5,33 @@ branding:
icon: "lock"
color: "gray-dark"
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: true
required: false
deprecationMessage: "'app_id' is deprecated and will be removed in a future version. Use 'app-id' instead."
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: true
required: false
deprecationMessage: "'private_key' is deprecated and will be removed in a future version. Use 'private-key' instead."
owner:
description: "GitHub App owner (defaults to current repository owner)"
required: false
repositories:
description: "Repositories to install the GitHub App on (defaults to current repository if owner is unset)"
required: false
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."
outputs:
token:
description: "GitHub installation access token"
+693 -5659
View File
File diff suppressed because it is too large Load Diff
+54 -17
View File
@@ -569,7 +569,12 @@ var require_proxy = __commonJS({
}
})();
if (proxyVar) {
return new URL(proxyVar);
try {
return new URL(proxyVar);
} catch (_a) {
if (!proxyVar.startsWith("http://") && !proxyVar.startsWith("https://"))
return new URL(`http://${proxyVar}`);
}
} else {
return void 0;
}
@@ -1001,6 +1006,19 @@ var require_lib = __commonJS({
}));
});
}
readBodyBuffer() {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
const chunks = [];
this.message.on("data", (chunk) => {
chunks.push(chunk);
});
this.message.on("end", () => {
resolve(Buffer.concat(chunks));
});
}));
});
}
};
exports.HttpClientResponse = HttpClientResponse;
function isHttps(requestUrl) {
@@ -1602,7 +1620,7 @@ var require_oidc_utils = __commonJS({
Error Code : ${error.statusCode}
Error Message: ${error.result.message}`);
Error Message: ${error.message}`);
});
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
if (!id_token) {
@@ -2278,7 +2296,7 @@ var require_dist_node2 = __commonJS({
});
module2.exports = __toCommonJS2(dist_src_exports);
var import_universal_user_agent = require_dist_node();
var VERSION = "9.0.0";
var VERSION = "9.0.1";
var userAgent = `octokit-endpoint.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}`;
var DEFAULTS = {
method: "GET",
@@ -2793,7 +2811,7 @@ var require_dist_node5 = __commonJS({
module2.exports = __toCommonJS2(dist_src_exports);
var import_endpoint = require_dist_node2();
var import_universal_user_agent = require_dist_node();
var VERSION = "8.1.1";
var VERSION = "8.1.2";
var import_is_plain_object = require_is_plain_object();
var import_request_error = require_dist_node4();
function getBufferResponse(response) {
@@ -2951,30 +2969,49 @@ var require_dist_node5 = __commonJS({
});
// post.js
var import_core2 = __toESM(require_core(), 1);
var import_request = __toESM(require_dist_node5(), 1);
var import_core = __toESM(require_core(), 1);
// lib/post.js
var import_core = __toESM(require_core(), 1);
async function post(core3, request2) {
const token = core3.getState("token");
if (!token)
async function post(core2, request2) {
const skipTokenRevoke = Boolean(
core2.getInput("skip-token-revoke") || core2.getInput("skip_token_revoke")
);
if (skipTokenRevoke) {
core2.info("Token revocation was skipped");
return;
}
const token = core2.getState("token");
if (!token) {
core2.info("Token is not set");
return;
}
await request2("DELETE /installation/token", {
headers: {
authorization: `token ${token}`
}
});
core3.info("Token revoked");
core2.info("Token revoked");
}
// post.js
post(import_core2.default, import_request.request).catch(
(error) => {
console.error(error);
import_core2.default.setFailed(error.message);
// lib/request.js
var import_request = __toESM(require_dist_node5(), 1);
var request_default = import_request.request.defaults({
baseUrl: process.env["GITHUB_API_URL"],
headers: {
"user-agent": "actions/create-github-app-token"
}
);
});
// post.js
post(
import_core.default,
request_default.defaults({
baseUrl: process.env["GITHUB_API_URL"]
})
).catch((error) => {
console.error(error);
import_core.default.setFailed(error.message);
});
/*! Bundled license information:
is-plain-object/dist/is-plain-object.js:
+97 -28
View File
@@ -1,56 +1,123 @@
// @ts-check
import core from "@actions/core";
import { createAppAuth } from "@octokit/auth-app";
import { request } from "@octokit/request";
/**
* @param {string} appId
* @param {string} privateKey
* @param {string} repository
* @param {core} core
* @param {createAppAuth} createAppAuth
* @param {request} request
* @param {string} owner
* @param {string} repositories
* @param {import("@actions/core")} core
* @param {import("@octokit/auth-app").createAppAuth} createAppAuth
* @param {import("@octokit/request").request} request
* @param {boolean} skipTokenRevoke
*/
export async function main(
appId,
privateKey,
repository,
owner,
repositories,
core,
createAppAuth,
request
request,
skipTokenRevoke
) {
// Get owner and repo name from GITHUB_REPOSITORY
const [owner, repo] = repository.split("/");
let parsedOwner = "";
let parsedRepositoryNames = "";
// If neither owner nor repositories are set, default to current repository
if (!owner && !repositories) {
[parsedOwner, parsedRepositoryNames] = String(
process.env.GITHUB_REPOSITORY
).split("/");
core.info(
`owner and repositories not set, creating token for the current repository ("${parsedRepositoryNames}")`
);
}
// If only an owner is set, default to all repositories from that owner
if (owner && !repositories) {
parsedOwner = owner;
core.info(
`repositories not set, creating token for all repositories for given owner "${owner}"`
);
}
// If repositories are set, but no owner, default to `GITHUB_REPOSITORY_OWNER`
if (!owner && repositories) {
parsedOwner = String(process.env.GITHUB_REPOSITORY_OWNER);
parsedRepositoryNames = repositories;
core.info(
`owner not set, creating owner for given repositories "${repositories}" in current owner ("${parsedOwner}")`
);
}
// If both owner and repositories are set, use those values
if (owner && repositories) {
parsedOwner = owner;
parsedRepositoryNames = repositories;
core.info(
`owner and repositories set, creating token for repositories "${repositories}" owned by "${owner}"`
);
}
const auth = createAppAuth({
appId,
privateKey,
request,
});
const appAuthentication = await auth({
type: "app",
});
// Get the installation ID
// https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#get-a-repository-installation-for-the-authenticated-app
const { data: installation } = await request(
"GET /repos/{owner}/{repo}/installation",
{
owner,
repo,
let authentication;
// If at least one repository is set, get installation ID from that repository
// https://docs.github.com/rest/apps/apps?apiVersion=2022-11-28#get-a-repository-installation-for-the-authenticated-app
if (parsedRepositoryNames) {
const response = await request("GET /repos/{owner}/{repo}/installation", {
owner: parsedOwner,
repo: parsedRepositoryNames.split(",")[0],
headers: {
authorization: `bearer ${appAuthentication.token}`,
},
}
);
});
// Create a new installation token
const authentication = await auth({
type: "installation",
installationId: installation.id,
repositoryNames: [repo],
});
// Get token for given repositories
authentication = await auth({
type: "installation",
installationId: response.data.id,
repositoryNames: parsedRepositoryNames.split(","),
});
} else {
// Otherwise get the installation for the owner, which can either be an organization or a user account
// https://docs.github.com/rest/apps/apps?apiVersion=2022-11-28#get-a-repository-installation-for-the-authenticated-app
const response = await request("GET /orgs/{org}/installation", {
org: parsedOwner,
headers: {
authorization: `bearer ${appAuthentication.token}`,
},
}).catch((error) => {
/* c8 ignore next */
if (error.status !== 404) throw error;
// https://docs.github.com/rest/apps/apps?apiVersion=2022-11-28#get-a-user-installation-for-the-authenticated-app
return request("GET /users/{username}/installation", {
username: parsedOwner,
headers: {
authorization: `bearer ${appAuthentication.token}`,
},
});
});
// Get token for for all repositories of the given installation
authentication = await auth({
type: "installation",
installationId: response.data.id,
});
}
// Register the token with the runner as a secret to ensure it is masked in logs
core.setSecret(authentication.token);
@@ -58,5 +125,7 @@ export async function main(
core.setOutput("token", authentication.token);
// Make token accessible to post function (so we can invalidate it)
core.saveState("token", authentication.token);
if (!skipTokenRevoke) {
core.saveState("token", authentication.token);
}
}
+16 -7
View File
@@ -1,17 +1,26 @@
// @ts-check
import core from "@actions/core";
import { request } from "@octokit/request";
/**
* @param {core} core
* @param {request} request
* @param {import("@actions/core")} core
* @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")
);
if (skipTokenRevoke) {
core.info("Token revocation was skipped");
return;
}
const token = core.getState("token");
if (!token) return;
if (!token) {
core.info("Token is not set");
return;
}
await request("DELETE /installation/token", {
headers: {
authorization: `token ${token}`,
+8
View File
@@ -0,0 +1,8 @@
import { request } from "@octokit/request";
export default request.defaults({
baseUrl: process.env["GITHUB_API_URL"],
headers: {
"user-agent": "actions/create-github-app-token",
},
});
+35 -9
View File
@@ -2,22 +2,48 @@
import core from "@actions/core";
import { createAppAuth } from "@octokit/auth-app";
import { request } from "@octokit/request";
import { main } from "./lib/main.js";
import request from "./lib/request.js";
if (!process.env.GITHUB_REPOSITORY) {
throw new Error("GITHUB_REPOSITORY missing, must be set to '<owner>/<repo>'");
}
const appId = core.getInput("app_id");
const privateKey = core.getInput("private_key");
if (!process.env.GITHUB_REPOSITORY_OWNER) {
throw new Error("GITHUB_REPOSITORY_OWNER missing, must be set to '<owner>'");
}
const repository = process.env.GITHUB_REPOSITORY;
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 owner = core.getInput("owner");
const repositories = core.getInput("repositories");
main(appId, privateKey, repository, core, createAppAuth, request).catch(
(error) => {
console.error(error);
core.setFailed(error.message);
}
const skipTokenRevoke = Boolean(
core.getInput("skip-token-revoke") || core.getInput("skip_token_revoke")
);
main(
appId,
privateKey,
owner,
repositories,
core,
createAppAuth,
request.defaults({
baseUrl: process.env["GITHUB_API_URL"],
}),
skipTokenRevoke
).catch((error) => {
/* c8 ignore next 3 */
console.error(error);
core.setFailed(error.message);
});
+3763 -150
View File
File diff suppressed because it is too large Load Diff
+14 -6
View File
@@ -2,21 +2,29 @@
"name": "create-github-app-token",
"private": true,
"type": "module",
"version": "1.1.5",
"version": "1.5.0",
"description": "GitHub Action for creating a GitHub App Installation Access Token",
"scripts": {
"build": "esbuild main.js post.js --bundle --outdir=dist --out-extension:.js=.cjs --platform=node --target=node16.16",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "c8 --100 ava tests/index.js",
"coverage": "c8 report --reporter html",
"postcoverage": "open-cli coverage/index.html"
},
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",
"@octokit/auth-app": "^6.0.0",
"@octokit/request": "^8.1.1"
"@actions/core": "^1.10.1",
"@octokit/auth-app": "^6.0.1",
"@octokit/request": "^8.1.2"
},
"devDependencies": {
"ava": "^5.3.1",
"c8": "^8.0.1",
"dotenv": "^16.3.1",
"esbuild": "^0.19.2"
"esbuild": "^0.19.4",
"execa": "^8.0.1",
"open-cli": "^7.2.0",
"undici": "^5.25.2",
"yaml": "^2.3.2"
},
"release": {
"branches": [
+11 -7
View File
@@ -1,13 +1,17 @@
// @ts-check
import core from "@actions/core";
import { request } from "@octokit/request";
import { post } from "./lib/post.js";
import request from "./lib/request.js";
post(core, request).catch(
(error) => {
console.error(error);
core.setFailed(error.message);
}
);
post(
core,
request.defaults({
baseUrl: process.env["GITHUB_API_URL"],
})
).catch((error) => {
/* c8 ignore next 3 */
console.error(error);
core.setFailed(error.message);
});
+19
View File
@@ -0,0 +1,19 @@
# Tests
Add one test file per scenario. You can run them in isolation with:
```bash
node tests/post-token-set.test.js
```
All tests are run together in [tests/index.js](index.js), which can be executed with ava
```
npx ava tests/index.js
```
or with npm
```
npm test
```
+16
View File
@@ -0,0 +1,16 @@
import { readFileSync } from "node:fs";
import * as url from "node:url";
import YAML from "yaml";
const action = YAML.parse(
readFileSync(
url.fileURLToPath(new URL("../action.yml", import.meta.url)),
"utf8"
)
);
for (const [key, value] of Object.entries(action.inputs)) {
if ("deprecationMessage" in value) {
console.log(`${key}${value.deprecationMessage}`);
}
}
+19
View File
@@ -0,0 +1,19 @@
import { readdirSync } from "node:fs";
import { execa } from "execa";
import test from "ava";
const tests = readdirSync("tests").filter((file) => file.endsWith(".test.js"));
for (const file of tests) {
test(file, async (t) => {
// Override Actions environment variables that change `core`s behavior
const env = {
GITHUB_OUTPUT: undefined,
GITHUB_STATE: undefined,
};
const { stderr, stdout } = await execa("node", [`tests/${file}`], { env });
t.snapshot(stderr, "stderr");
t.snapshot(stdout, "stdout");
});
}
+9
View File
@@ -0,0 +1,9 @@
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);
}
+9
View File
@@ -0,0 +1,9 @@
process.env.GITHUB_REPOSITORY = "actions/create-github-app-token";
delete process.env.GITHUB_REPOSITORY_OWNER;
// Verify `main` exits with an error when `GITHUB_REPOSITORY_OWNER` is missing.
try {
await import("../main.js");
} catch (error) {
console.error(error.message);
}
+10
View File
@@ -0,0 +1,10 @@
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);
}
+8
View File
@@ -0,0 +1,8 @@
delete process.env.GITHUB_REPOSITORY;
// Verify `main` exits with an error when `GITHUB_REPOSITORY` is missing.
try {
await import("../main.js");
} catch (error) {
console.error(error.message);
}
@@ -0,0 +1,7 @@
import { test } from "./main.js";
// Verify `main` successfully obtains a token when the `owner` and `repositories` inputs are set (and the latter is a list of repos).
await test(() => {
process.env.INPUT_OWNER = process.env.GITHUB_REPOSITORY_OWNER;
process.env.INPUT_REPOSITORIES = `${process.env.GITHUB_REPOSITORY},actions/toolkit`;
});
@@ -0,0 +1,7 @@
import { test } from "./main.js";
// Verify `main` successfully obtains a token when the `owner` and `repositories` inputs are set (and the latter is a single repo).
await test(() => {
process.env.INPUT_OWNER = process.env.GITHUB_REPOSITORY_OWNER;
process.env.INPUT_REPOSITORIES = process.env.GITHUB_REPOSITORY;
});
@@ -0,0 +1,25 @@
import { test } from "./main.js";
// Verify `main` successfully obtains a token when the `owner` input is set (to an org), but the `repositories` input isnt set.
await test((mockPool) => {
process.env.INPUT_OWNER = process.env.GITHUB_REPOSITORY_OWNER;
delete process.env.INPUT_REPOSITORIES;
// Mock installation id request
const mockInstallationId = "123456";
mockPool
.intercept({
path: `/orgs/${process.env.INPUT_OWNER}/installation`,
method: "GET",
headers: {
accept: "application/vnd.github.v3+json",
"user-agent": "actions/create-github-app-token",
// Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
},
})
.reply(
200,
{ id: mockInstallationId },
{ headers: { "content-type": "application/json" } }
);
});
@@ -0,0 +1,36 @@
import { test } from "./main.js";
// Verify `main` successfully obtains a token when the `owner` input is set (to a user), but the `repositories` input isnt set.
await test((mockPool) => {
process.env.INPUT_OWNER = "smockle";
delete process.env.INPUT_REPOSITORIES;
// Mock installation id request
const mockInstallationId = "123456";
mockPool
.intercept({
path: `/orgs/${process.env.INPUT_OWNER}/installation`,
method: "GET",
headers: {
accept: "application/vnd.github.v3+json",
"user-agent": "actions/create-github-app-token",
// Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
},
})
.reply(404);
mockPool
.intercept({
path: `/users/${process.env.INPUT_OWNER}/installation`,
method: "GET",
headers: {
accept: "application/vnd.github.v3+json",
"user-agent": "actions/create-github-app-token",
// Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
},
})
.reply(
200,
{ id: mockInstallationId },
{ headers: { "content-type": "application/json" } }
);
});
@@ -0,0 +1,7 @@
import { test } from "./main.js";
// Verify `main` successfully obtains a token when the `owner` input is not set, but the `repositories` input is set.
await test(() => {
delete process.env.INPUT_OWNER;
process.env.INPUT_REPOSITORIES = process.env.GITHUB_REPOSITORY;
});
@@ -0,0 +1,25 @@
import { test } from "./main.js";
// Verify `main` successfully obtains a token when neither the `owner` nor `repositories` input is set.
await test((mockPool) => {
delete process.env.INPUT_OWNER;
delete process.env.INPUT_REPOSITORIES;
// Mock installation id request
const mockInstallationId = "123456";
mockPool
.intercept({
path: `/repos/${process.env.GITHUB_REPOSITORY}/installation`,
method: "GET",
headers: {
accept: "application/vnd.github.v3+json",
"user-agent": "actions/create-github-app-token",
// Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
},
})
.reply(
200,
{ id: mockInstallationId },
{ headers: { "content-type": "application/json" } }
);
});
+96
View File
@@ -0,0 +1,96 @@
// Base for all `main` tests.
// @ts-check
import { MockAgent, setGlobalDispatcher } from "undici";
export async function test(cb = (_mockPool) => {}) {
// Set required environment variables and inputs
process.env.GITHUB_REPOSITORY_OWNER = "actions";
process.env.GITHUB_REPOSITORY = "actions/create-github-app-token";
// inputs are set as environment variables with the prefix INPUT_
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
process.env["INPUT_APP-ID"] = "123456";
process.env["INPUT_PRIVATE-KEY"] = `-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA280nfuUM9w00Ib9E2rvZJ6Qu3Ua3IqR34ZlK53vn/Iobn2EL
Z9puc5Q/nFBU15NKwHyQNb+OG2hTCkjd1Xi9XPzEOH1r42YQmTGq8YCkUSkk6KZA
5dnhLwN9pFquT9fQgrf4r1D5GJj3rqvj8JDr1sBmunArqY5u4gziSrIohcjLIZV0
cIMz/RUIMe/EAsNeiwzEteHAtf/WpMs+OfF94SIUrDlkPr0H0H3DER8l1HZAvE0e
eD3ZJ6njrF6UHQWDVrekSTB0clpVTTU9TMpe+gs2nnFww9G8As+WsW8xHVjVipJy
AwqBhiR+s7wlcbh2i0NQqt8GL9/jIFTmleiwsQIDAQABAoIBAHNyP8pgl/yyzKzk
/0871wUBMTQ7zji91dGCaFtJM0HrcDK4D/uOOPEv7nE1qDpKPLr5Me1pHUS7+NGw
EAPtlNhgUtew2JfppdIwyi5qeOPADoi7ud6AH8xHsxg+IMwC+JuP8WhzyUHoJj9y
PRi/pX94Mvy9qdE25HqKddjx1mLdaHhxqPkr16/em23uYZqm1lORsCPD3vTlthj7
WiEbBSqmpYvjj8iFP4yFk2N+LvuWgSilRzq1Af3qE7PUp4xhjmcOPs78Sag1T7nl
ww/pgqCegISABHik7j++/5T+UlI5cLsyp/XENU9zAd4kCIczwNKpun2bn+djJdft
ravyX4ECgYEA+k2mHfi1zwKF3wT+cJbf30+uXrJczK2yZ33//4RKnhBaq7nSbQAI
nhWz2JESBK0TEo0+L7yYYq3HnT9vcES5R1NxzruH9wXgxssSx3JUj6w1raXYPh3B
+1XpYQsa6/bo2LmBELEx47F8FQbNgD5dmTJ4jBrf6MV4rRh9h6Bs7UkCgYEA4M3K
eAw52c2MNMIxH/LxdOQtEBq5GMu3AQC8I64DSSRrAoiypfEgyTV6S4gWJ5TKgYfD
zclnOVJF+tITe3neO9wHoZp8iCjCnoijcT6p2cJ4IaW68LEHPOokWBk0EpLjF4p2
7sFi9+lUpXYXfCN7aMJ77QpGzB7dNsBf0KUxMCkCgYEAjw/mjGbk82bLwUaHby6s
0mQmk7V6WPpGZ+Sadx7TzzglutVAslA8nK5m1rdEBywtJINaMcqnhm8xEm15cj+1
blEBUVnaQpQ3fyf+mcR9FIknPRL3X7l+b/sQowjH4GqFd6m/XR0KGMwO0a3Lsyry
MGeqgtmxdMe5S6YdyXEmERECgYAgQsgklDSVIh9Vzux31kh6auhgoEUh3tJDbZSS
Vj2YeIZ21aE1mTYISglj34K2aW7qSc56sMWEf18VkKJFHQccdgYOVfo7HAZZ8+fo
r4J2gqb0xTDfq7gLMNrIXc2QQM4gKbnJp60JQM3p9NmH8huavBZGvSvNzTwXyGG3
so0tiQKBgGQXZaxaXhYUcxYHuCkQ3V4Vsj3ezlM92xXlP32SGFm3KgFhYy9kATxw
Cax1ytZzvlrKLQyQFVK1COs2rHt7W4cJ7op7C8zXfsigXCiejnS664oAuX8sQZID
x3WQZRiXlWejSMUAHuMwXrhGlltF3lw83+xAjnqsVp75kGS6OH61
-----END RSA PRIVATE KEY-----`; // This key is invalidated. Its from https://github.com/octokit/auth-app.js/issues/465#issuecomment-1564998327.
// Set up mocking
const mockAgent = new MockAgent();
mockAgent.disableNetConnect();
setGlobalDispatcher(mockAgent);
const mockPool = mockAgent.get("https://api.github.com");
// Calling `auth({ type: "app" })` to obtain a JWT doesnt make network requests, so no need to intercept.
// Mock installation id request
const mockInstallationId = "123456";
const owner = process.env.INPUT_OWNER ?? process.env.GITHUB_REPOSITORY_OWNER;
const repo = encodeURIComponent(
(process.env.INPUT_REPOSITORIES ?? process.env.GITHUB_REPOSITORY).split(
","
)[0]
);
mockPool
.intercept({
path: `/repos/${owner}/${repo}/installation`,
method: "GET",
headers: {
accept: "application/vnd.github.v3+json",
"user-agent": "actions/create-github-app-token",
// Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
},
})
.reply(
200,
{ id: mockInstallationId },
{ headers: { "content-type": "application/json" } }
);
// Mock installation access token request
const mockInstallationAccessToken =
"ghs_16C7e42F292c6912E7710c838347Ae178B4a"; // This token is invalidated. Its from https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-an-installation-access-token-for-an-app.
mockPool
.intercept({
path: `/app/installations/${mockInstallationId}/access_tokens`,
method: "POST",
headers: {
accept: "application/vnd.github.v3+json",
"user-agent": "actions/create-github-app-token",
// Note: Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
},
})
.reply(
201,
{ token: mockInstallationAccessToken },
{ headers: { "content-type": "application/json" } }
);
// Run the callback
cb(mockPool);
// Run the main script
await import("../main.js");
}
+25
View File
@@ -0,0 +1,25 @@
import { MockAgent, setGlobalDispatcher } from "undici";
// state variables are set as environment variables with the prefix STATE_
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#sending-values-to-the-pre-and-post-actions
process.env.STATE_token = "secret123";
const mockAgent = new MockAgent();
setGlobalDispatcher(mockAgent);
// Provide the base url to the request
const mockPool = mockAgent.get("https://api.github.com");
// intercept the request
mockPool
.intercept({
path: "/installation/token",
method: "DELETE",
headers: {
authorization: "token secret123",
},
})
.reply(204);
await import("../post.js");
+29
View File
@@ -0,0 +1,29 @@
import { MockAgent, setGlobalDispatcher } from "undici";
// state variables are set as environment variables with the prefix STATE_
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#sending-values-to-the-pre-and-post-actions
process.env.STATE_token = "secret123";
// inputs are set as environment variables with the prefix INPUT_
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
process.env["INPUT_SKIP-TOKEN-REVOKE"] = "true";
const mockAgent = new MockAgent();
setGlobalDispatcher(mockAgent);
// Provide the base url to the request
const mockPool = mockAgent.get("https://api.github.com");
// intercept the request
mockPool
.intercept({
path: "/installation/token",
method: "DELETE",
headers: {
authorization: "token secret123",
},
})
.reply(204);
await import("../post.js");
+5
View File
@@ -0,0 +1,5 @@
// state variables are set as environment variables with the prefix STATE_
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#sending-values-to-the-pre-and-post-actions
delete process.env.STATE_token;
await import("../post.js");
+171
View File
@@ -0,0 +1,171 @@
# Snapshot report for `tests/index.js`
The actual snapshot is saved in `index.js.snap`.
Generated by [AVA](https://avajs.dev).
## action-deprecated-inputs.test.js
> stderr
''
> 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-missing-app-id.test.js
> stderr
'Input required and not supplied: app-id'
> stdout
''
## main-missing-owner.test.js
> stderr
'GITHUB_REPOSITORY_OWNER missing, must be set to \'<owner>\''
> stdout
''
## main-missing-private-key.test.js
> stderr
'Input required and not supplied: private-key'
> stdout
''
## main-missing-repository.test.js
> stderr
'GITHUB_REPOSITORY missing, must be set to \'<owner>/<repo>\''
> stdout
''
## main-token-get-owner-set-repo-set-to-many.test.js
> stderr
''
> stdout
`owner and repositories set, creating token for repositories "actions/create-github-app-token,actions/toolkit" owned by "actions"␊
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a`
## main-token-get-owner-set-repo-set-to-one.test.js
> stderr
''
> stdout
`owner and repositories set, creating token for repositories "actions/create-github-app-token" owned by "actions"␊
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a`
## main-token-get-owner-set-to-org-repo-unset.test.js
> stderr
''
> stdout
`repositories not set, creating token for all repositories for given owner "actions"␊
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a`
## main-token-get-owner-set-to-user-repo-unset.test.js
> stderr
''
> stdout
`repositories not set, creating token for all repositories for given owner "smockle"␊
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a`
## main-token-get-owner-unset-repo-set.test.js
> stderr
''
> stdout
`owner not set, creating owner for given repositories "actions/create-github-app-token" in current owner ("actions")␊
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a`
## main-token-get-owner-unset-repo-unset.test.js
> stderr
''
> stdout
`owner and repositories not set, creating token for the current repository ("create-github-app-token")␊
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a`
## post-token-set.test.js
> stderr
''
> stdout
'Token revoked'
## post-token-skipped.test.js
> stderr
''
> stdout
'Token revocation was skipped'
## post-token-unset.test.js
> stderr
''
> stdout
'Token is not set'
Binary file not shown.