Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 803e078eb5 | |||
| 9cf7227dfb | |||
| 7bbad93287 | |||
| e5568a0249 | |||
| cb1fcdda59 | |||
| 12aa81137b | |||
| 950f8a0559 | |||
| c04bb41e61 | |||
| 75a13e1cc6 | |||
| d1dfb47fa4 | |||
| 847634eeb3 |
@@ -0,0 +1 @@
|
||||
* @gr2m @parkerbxyz @actions/create-github-app-token-maintainers
|
||||
@@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
@@ -26,12 +26,7 @@ jobs:
|
||||
with:
|
||||
app_id: ${{ vars.RELEASER_APP_ID }}
|
||||
private_key: ${{ secrets.RELEASER_APP_PRIVATE_KEY }}
|
||||
|
||||
- id: commit
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: "build: update dist files"
|
||||
- run: npm i semantic-release-plugin-github-breaking-version-tag
|
||||
- run: npm install --no-save @semantic-release/git semantic-release-plugin-github-breaking-version-tag
|
||||
- run: npx semantic-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
name: test
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
demo:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16.16'
|
||||
cache: 'npm'
|
||||
node-version: "16.16"
|
||||
cache: "npm"
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- uses: ./ # Uses the action in the root directory
|
||||
id: demo
|
||||
with:
|
||||
app_id: ${{ secrets.APP_ID }}
|
||||
private_key: ${{ secrets.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:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# `gr2m/github-app-token-action`
|
||||
# Create GitHub App Token
|
||||
|
||||
> GitHub Action for creating a GitHub App Installation Access Token
|
||||
GitHub Action for creating a GitHub App installation access token.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
hello-world:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: gr2m/github-app-token-action@v1
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
app_id: ${{ vars.APP_ID }}
|
||||
@@ -31,24 +31,6 @@ jobs:
|
||||
body: "Hello, World!"
|
||||
```
|
||||
|
||||
### Limit the app's permissions and access to repositories
|
||||
|
||||
```yaml
|
||||
on: [issues]
|
||||
|
||||
jobs:
|
||||
with-scoped-token:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: gr2m/github-app-token-action@v1
|
||||
id: app-token
|
||||
with:
|
||||
# required
|
||||
app_id: ${{ vars.APP_ID }}
|
||||
private_key: ${{ secrets.PRIVATE_KEY }}
|
||||
# do something with the token
|
||||
```
|
||||
|
||||
### Use app token with `actions/checkout`
|
||||
|
||||
```yaml
|
||||
@@ -58,7 +40,7 @@ jobs:
|
||||
auto-format:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: gr2m/github-app-token-action@v1
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
# required
|
||||
@@ -79,29 +61,29 @@ jobs:
|
||||
|
||||
### `app_id`
|
||||
|
||||
**Required:** GitHub app ID.
|
||||
**Required:** GitHub App ID.
|
||||
|
||||
### `private_key`
|
||||
|
||||
**Required:** GitHub app private key.
|
||||
**Required:** GitHub App private key.
|
||||
|
||||
## Outputs
|
||||
|
||||
### `token`
|
||||
|
||||
GitHub installation access token.
|
||||
GitHub App installation access token.
|
||||
|
||||
## How it works
|
||||
|
||||
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
|
||||
2. The token inherits all the installation's permissions
|
||||
3. The token is set as output `token` which can be used in subsequent steps
|
||||
1. The token is scoped to the current repository.
|
||||
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.
|
||||
|
||||
> **Note**
|
||||
> [!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.
|
||||
|
||||
## License
|
||||
|
||||
+12
-9
@@ -1,17 +1,20 @@
|
||||
name: 'github-app-token'
|
||||
description: ''
|
||||
author: 'Gregor Martynus and Parker Brown'
|
||||
name: "Create GitHub App Token"
|
||||
description: "GitHub Action for creating a GitHub App installation access token"
|
||||
author: "Gregor Martynus and Parker Brown"
|
||||
branding:
|
||||
icon: "lock"
|
||||
color: "gray-dark"
|
||||
inputs:
|
||||
app_id:
|
||||
description: 'GitHub app ID'
|
||||
description: "GitHub App ID"
|
||||
required: true
|
||||
private_key:
|
||||
description: 'GitHub app private key'
|
||||
description: "GitHub App private key"
|
||||
required: true
|
||||
outputs:
|
||||
token:
|
||||
description: 'GitHub installation access token'
|
||||
description: "GitHub installation access token"
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'dist/main.cjs'
|
||||
post: 'dist/post.cjs'
|
||||
using: "node20"
|
||||
main: "dist/main.cjs"
|
||||
post: "dist/post.cjs"
|
||||
|
||||
+18
-2
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "app-token-action",
|
||||
"name": "create-github-app-token",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.5",
|
||||
"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",
|
||||
@@ -22,6 +22,22 @@
|
||||
"branches": [
|
||||
"+([0-9]).x",
|
||||
"main"
|
||||
],
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/github",
|
||||
"semantic-release-plugin-github-breaking-version-tag",
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": [
|
||||
"package.json",
|
||||
"dist/*"
|
||||
],
|
||||
"message": "build(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user