Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7989d206df | ||
|
|
1b10c78c78 | ||
|
|
07e2b76066 | ||
|
|
ea0121618b |
17
.github/workflows/publish-immutable-action.yml
vendored
17
.github/workflows/publish-immutable-action.yml
vendored
@@ -1,17 +0,0 @@
|
|||||||
name: 'Publish Immutable Action'
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
id-token: write
|
|
||||||
packages: write
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: Publish Immutable Action
|
|
||||||
uses: actions/publish-immutable-action@v0.0.4
|
|
||||||
48
README.md
48
README.md
@@ -9,8 +9,8 @@ GitHub Action for creating a GitHub App installation access token.
|
|||||||
In order to use this action, you need to:
|
In order to use this action, you need to:
|
||||||
|
|
||||||
1. [Register new GitHub App](https://docs.github.com/apps/creating-github-apps/setting-up-a-github-app/creating-a-github-app).
|
1. [Register new GitHub App](https://docs.github.com/apps/creating-github-apps/setting-up-a-github-app/creating-a-github-app).
|
||||||
2. [Store the App's Client ID in your repository environment variables](https://docs.github.com/actions/how-tos/write-workflows/choose-what-workflows-do/use-variables#defining-configuration-variables-for-multiple-workflows) (example: `GITHUB_APP_CLIENT_ID`).
|
2. [Store the App's Client ID in your repository variables](https://docs.github.com/actions/how-tos/write-workflows/choose-what-workflows-do/use-variables#defining-configuration-variables-for-multiple-workflows) (example: `APP_CLIENT_ID`).
|
||||||
3. [Store the App's private key in your repository secrets](https://docs.github.com/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets?tool=webui#creating-secrets-for-a-repository) (example: `GITHUB_APP_PRIVATE_KEY`).
|
3. [Store the App's private key in your repository secrets](https://docs.github.com/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets?tool=webui#creating-secrets-for-a-repository) (example: `APP_PRIVATE_KEY`).
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> An installation access token expires after 1 hour. Please [see this comment](https://github.com/actions/create-github-app-token/issues/121#issuecomment-2043214796) for alternative approaches if you have long-running processes.
|
> An installation access token expires after 1 hour. Please [see this comment](https://github.com/actions/create-github-app-token/issues/121#issuecomment-2043214796) for alternative approaches if you have long-running processes.
|
||||||
@@ -31,8 +31,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
- uses: ./actions/staging-tests
|
- uses: ./actions/staging-tests
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.app-token.outputs.token }}
|
token: ${{ steps.app-token.outputs.token }}
|
||||||
@@ -51,8 +51,8 @@ jobs:
|
|||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
# required
|
# required
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.app-token.outputs.token }}
|
token: ${{ steps.app-token.outputs.token }}
|
||||||
@@ -77,8 +77,8 @@ jobs:
|
|||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
# required
|
# required
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
- name: Get GitHub App User ID
|
- name: Get GitHub App User ID
|
||||||
id: get-user-id
|
id: get-user-id
|
||||||
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
|
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
|
||||||
@@ -102,8 +102,8 @@ jobs:
|
|||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
# required
|
# required
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
- name: Get GitHub App User ID
|
- name: Get GitHub App User ID
|
||||||
id: get-user-id
|
id: get-user-id
|
||||||
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
|
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
|
||||||
@@ -138,8 +138,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
owner: ${{ github.repository_owner }}
|
owner: ${{ github.repository_owner }}
|
||||||
- uses: peter-evans/create-or-update-comment@v4
|
- uses: peter-evans/create-or-update-comment@v4
|
||||||
with:
|
with:
|
||||||
@@ -160,8 +160,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
owner: ${{ github.repository_owner }}
|
owner: ${{ github.repository_owner }}
|
||||||
repositories: |
|
repositories: |
|
||||||
repo1
|
repo1
|
||||||
@@ -185,8 +185,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
owner: another-owner
|
owner: another-owner
|
||||||
- uses: peter-evans/create-or-update-comment@v4
|
- uses: peter-evans/create-or-update-comment@v4
|
||||||
with:
|
with:
|
||||||
@@ -210,8 +210,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
owner: ${{ github.repository_owner }}
|
owner: ${{ github.repository_owner }}
|
||||||
permission-issues: write
|
permission-issues: write
|
||||||
- uses: peter-evans/create-or-update-comment@v4
|
- uses: peter-evans/create-or-update-comment@v4
|
||||||
@@ -252,8 +252,8 @@ jobs:
|
|||||||
- uses: actions/create-github-app-token@v3
|
- uses: actions/create-github-app-token@v3
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
owner: ${{ matrix.owners-and-repos.owner }}
|
owner: ${{ matrix.owners-and-repos.owner }}
|
||||||
repositories: ${{ join(matrix.owners-and-repos.repos) }}
|
repositories: ${{ join(matrix.owners-and-repos.repos) }}
|
||||||
- uses: octokit/request-action@v2.x
|
- uses: octokit/request-action@v2.x
|
||||||
@@ -310,8 +310,8 @@ If you set `HTTP_PROXY` or `HTTPS_PROXY`, also set `NODE_USE_ENV_PROXY: "1"` on
|
|||||||
NO_PROXY: github.example.com
|
NO_PROXY: github.example.com
|
||||||
NODE_USE_ENV_PROXY: "1"
|
NODE_USE_ENV_PROXY: "1"
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
@@ -334,14 +334,14 @@ steps:
|
|||||||
- name: Decode the GitHub App Private Key
|
- name: Decode the GitHub App Private Key
|
||||||
id: decode
|
id: decode
|
||||||
run: |
|
run: |
|
||||||
private_key=$(echo "${{ secrets.GITHUB_APP_PRIVATE_KEY }}" | base64 -d | awk 'BEGIN {ORS="\\n"} {print}' | head -c -2) &> /dev/null
|
private_key=$(echo "${{ secrets.APP_PRIVATE_KEY }}" | base64 -d | awk 'BEGIN {ORS="\\n"} {print}' | head -c -2) &> /dev/null
|
||||||
echo "::add-mask::$private_key"
|
echo "::add-mask::$private_key"
|
||||||
echo "private-key=$private_key" >> "$GITHUB_OUTPUT"
|
echo "private-key=$private_key" >> "$GITHUB_OUTPUT"
|
||||||
- name: Generate GitHub App Token
|
- name: Generate GitHub App Token
|
||||||
id: app-token
|
id: app-token
|
||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v3
|
||||||
with:
|
with:
|
||||||
client-id: ${{ vars.GITHUB_APP_CLIENT_ID }}
|
client-id: ${{ vars.APP_CLIENT_ID }}
|
||||||
private-key: ${{ steps.decode.outputs.private-key }}
|
private-key: ${{ steps.decode.outputs.private-key }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
2
dist/main.cjs
vendored
2
dist/main.cjs
vendored
@@ -23352,7 +23352,7 @@ async function run() {
|
|||||||
ensureNativeProxySupport();
|
ensureNativeProxySupport();
|
||||||
const clientId = getInput("client-id") || getInput("app-id");
|
const clientId = getInput("client-id") || getInput("app-id");
|
||||||
if (!clientId) {
|
if (!clientId) {
|
||||||
throw new Error("Either 'client-id' or 'app-id' input must be set");
|
throw new Error("The 'client-id' (or deprecated 'app-id') input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.");
|
||||||
}
|
}
|
||||||
const privateKey = getInput("private-key");
|
const privateKey = getInput("private-key");
|
||||||
const owner = getInput("owner");
|
const owner = getInput("owner");
|
||||||
|
|||||||
2
main.js
2
main.js
@@ -20,7 +20,7 @@ async function run() {
|
|||||||
|
|
||||||
const clientId = core.getInput("client-id") || core.getInput("app-id");
|
const clientId = core.getInput("client-id") || core.getInput("app-id");
|
||||||
if (!clientId) {
|
if (!clientId) {
|
||||||
throw new Error("Either 'client-id' or 'app-id' input must be set");
|
throw new Error("The 'client-id' (or deprecated 'app-id') input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.");
|
||||||
}
|
}
|
||||||
const privateKey = core.getInput("private-key");
|
const privateKey = core.getInput("private-key");
|
||||||
const owner = core.getInput("owner");
|
const owner = core.getInput("owner");
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "create-github-app-token",
|
"name": "create-github-app-token",
|
||||||
"version": "3.1.0",
|
"version": "3.1.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "create-github-app-token",
|
"name": "create-github-app-token",
|
||||||
"version": "3.1.0",
|
"version": "3.1.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^3.0.0",
|
"@actions/core": "^3.0.0",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "create-github-app-token",
|
"name": "create-github-app-token",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "3.1.0",
|
"version": "3.1.1",
|
||||||
"description": "GitHub Action for creating a GitHub App Installation Access Token",
|
"description": "GitHub Action for creating a GitHub App Installation Access Token",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.4.0"
|
"node": ">=24.4.0"
|
||||||
|
|||||||
@@ -56,11 +56,11 @@ POST /api/v3/app/installations/123456/access_tokens
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-missing-client-and-app-id.test.js > stderr 1`] = `
|
exports[`main-missing-client-and-app-id.test.js > stderr 1`] = `
|
||||||
Either 'client-id' or 'app-id' input must be set
|
The 'client-id' (or deprecated 'app-id') input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-missing-client-and-app-id.test.js > stdout 1`] = `
|
exports[`main-missing-client-and-app-id.test.js > stdout 1`] = `
|
||||||
::error::Either 'client-id' or 'app-id' input must be set
|
::error::The 'client-id' (or deprecated 'app-id') input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`main-missing-owner.test.js > stderr 1`] = `
|
exports[`main-missing-owner.test.js > stderr 1`] = `
|
||||||
|
|||||||
Reference in New Issue
Block a user