Compare commits

...

10 Commits

Author SHA1 Message Date
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
semantic-release-bot 17cde8a7d8 build(release): 1.1.5 [skip ci]
## [1.1.5](https://github.com/actions/create-github-app-token/compare/v1.1.4...v1.1.5) (2023-08-28)

### Bug Fixes

* **release:** update version in `package.json` ([#35](https://github.com/actions/create-github-app-token/issues/35)) ([1dccc4c](https://github.com/actions/create-github-app-token/commit/1dccc4ccc6e1df7d6adc1bde339ce0d7a2ea7df7)), closes [#34](https://github.com/actions/create-github-app-token/issues/34)
2023-08-28 22:38:26 +00:00
Gregor Martynus 1dccc4ccc6 fix(release): update version in package.json (#35)
closes #34

Co-authored-by: Parker Brown <17183625+parkerbxyz@users.noreply.github.com>
2023-08-28 15:37:47 -07:00
semantic-release-bot 35d8ea9fdb build(release): 1.1.4 [skip ci]
## [1.1.4](https://github.com/actions/create-github-app-token/compare/v1.1.3...v1.1.4) (2023-08-28)

### Bug Fixes

* **release:** build `dist/` before release ([#33](https://github.com/actions/create-github-app-token/issues/33)) ([9a6a017](https://github.com/actions/create-github-app-token/commit/9a6a017c104eb1b36533ee8195e814f567934ce8)), closes [#32](https://github.com/actions/create-github-app-token/issues/32)
2023-08-28 22:29:27 +00:00
Gregor Martynus 9a6a017c10 fix(release): build dist/ before release (#33)
closes #32
2023-08-28 15:28:55 -07:00
David Sanders 2540ed49e5 fix: check for token before revoking (#30)
Check before trying to revoke the token, in case the token generation
failed. Otherwise the post step will throw an error.

---------

Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
2023-08-28 15:14:31 -07:00
Josh Gross 5611f921d9 docs(README): clarify token masking (#29)
With #13, this action is explicitly masking the token so we don't need to mention that we're relying on a specific format of GitHub tokens being masked by the runner.
2023-08-25 21:51:50 -07:00
10 changed files with 1112 additions and 6810 deletions
+2 -1
View File
@@ -23,6 +23,7 @@ jobs:
with:
token: ${{ steps.app-token.outputs.token }}
- run: npm install --no-save @semantic-release/git semantic-release-plugin-github-breaking-version-tag
- run: npx semantic-release
- run: npm run build
- run: npx semantic-release --debug
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
+1 -1
View File
@@ -81,7 +81,7 @@ The action creates an installation access token using [the `POST /app/installati
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.
5. The token is masked, it cannot be logged accidentally. That is not a feature by the action, but by the GitHub Actions runner itself, due to the specific format of GitHub tokens.
5. The token is masked, it cannot be logged accidentally.
> [!NOTE]
> Installation permissions can differ from the app's permissions they belong to. Installation permissions are set when an app is installed on an account. When the app adds more permissions after the installation, an account administrator will have to approve the new permissions before they are set on the installation.
+805 -3566
View File
File diff suppressed because one or more lines are too long
+262 -3215
View File
File diff suppressed because one or more lines are too long
+4 -7
View File
@@ -1,16 +1,12 @@
// @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 {import("@actions/core")} core
* @param {import("@octokit/auth-app").createAppAuth} createAppAuth
* @param {import("@octokit/request").request} request
*/
export async function main(
appId,
@@ -26,6 +22,7 @@ export async function main(
const auth = createAppAuth({
appId,
privateKey,
request,
});
const appAuthentication = await auth({
+4 -5
View File
@@ -1,15 +1,14 @@
// @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 token = core.getState("token");
if (!token) 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",
},
});
+14 -7
View File
@@ -2,9 +2,9 @@
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>'");
@@ -15,9 +15,16 @@ const privateKey = core.getInput("private_key");
const repository = process.env.GITHUB_REPOSITORY;
main(appId, privateKey, repository, core, createAppAuth, request).catch(
(error) => {
console.error(error);
core.setFailed(error.message);
}
);
main(
appId,
privateKey,
repository,
core,
createAppAuth,
request.defaults({
baseUrl: process.env["GITHUB_API_URL"],
})
).catch((error) => {
console.error(error);
core.setFailed(error.message);
});
+2 -1
View File
@@ -2,7 +2,7 @@
"name": "create-github-app-token",
"private": true,
"type": "module",
"version": "1.0.5",
"version": "1.2.1",
"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",
@@ -27,6 +27,7 @@
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
"@semantic-release/npm",
"semantic-release-plugin-github-breaking-version-tag",
[
"@semantic-release/git",
+10 -7
View File
@@ -1,13 +1,16 @@
// @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) => {
console.error(error);
core.setFailed(error.message);
});