Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49ce228ea7 | |||
| c08c5ace34 | |||
| c72844caa4 | |||
| ede6c15881 | |||
| 17cde8a7d8 | |||
| 1dccc4ccc6 | |||
| 35d8ea9fdb | |||
| 9a6a017c10 | |||
| 2540ed49e5 | |||
| 5611f921d9 |
@@ -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 }}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Vendored
+805
-3566
File diff suppressed because one or more lines are too long
Vendored
+262
-3215
File diff suppressed because one or more lines are too long
+4
-7
@@ -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
@@ -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}`,
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
});
|
||||
@@ -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
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user