Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Commit 0470095

Browse files
committed
Initial commit
0 parents  commit 0470095

File tree

13 files changed

+2295
-0
lines changed

13 files changed

+2295
-0
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!.eslintrc.js
2+
/dist/

.eslintrc.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"use strict";
2+
3+
module.exports = {
4+
// eslint-disable-next-line unicorn/prevent-abbreviations
5+
env: {
6+
es6: true,
7+
},
8+
extends: [
9+
"plugin:unicorn/recommended",
10+
"xo",
11+
"xo-typescript",
12+
"prettier",
13+
"prettier/@typescript-eslint",
14+
],
15+
parser: "@typescript-eslint/parser",
16+
parserOptions: {
17+
ecmaVersion: 2018,
18+
project: "tsconfig.json",
19+
sourceType: "module",
20+
},
21+
plugins: ["sort-destructure-keys", "typescript-sort-keys", "unicorn"],
22+
root: true,
23+
rules: {
24+
// @actions/github uses a lot of snake_case keys.
25+
"@typescript-eslint/camelcase": "off",
26+
// TypeScript is good at type inference and already requires types where they matter: exported symbols.
27+
"@typescript-eslint/explicit-function-return-type": "off",
28+
// We use sort-keys instead.
29+
"@typescript-eslint/member-ordering": "off",
30+
"arrow-body-style": "error",
31+
// Forbid function declarations
32+
"func-style": ["error", "expression", { allowArrowFunctions: true }],
33+
"no-console": "error",
34+
// TypeScript already takes care of that. See https://github.com/bradzacher/eslint-plugin-typescript/issues/110.
35+
"no-undef": "off",
36+
"object-shorthand": [
37+
"error",
38+
"always",
39+
{ avoidExplicitReturnArrows: true },
40+
],
41+
"sort-destructure-keys/sort-destructure-keys": [
42+
"error",
43+
{ caseSensitive: false },
44+
],
45+
"sort-keys": [
46+
"error",
47+
"asc",
48+
{ caseSensitive: false, minKeys: 2, natural: true },
49+
],
50+
"typescript-sort-keys/interface": "error",
51+
"typescript-sort-keys/string-enum": "error",
52+
},
53+
};

.github/workflows/publish.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Publish
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
jobs:
8+
publish:
9+
name: Publish
10+
runs-on: ubuntu-18.04
11+
steps:
12+
- uses: actions/checkout@v1
13+
- uses: dylanvann/[email protected]
14+
with:
15+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Test
2+
on:
3+
push:
4+
branches-ignore:
5+
- master
6+
7+
jobs:
8+
test:
9+
name: Test
10+
runs-on: ubuntu-18.04
11+
steps:
12+
- uses: actions/checkout@v1
13+
- name: Install
14+
run: yarn install --frozen-lockfile
15+
- name: Build
16+
run: yarn run build
17+
- name: ESLint
18+
run: yarn run eslint
19+
- name: Prettier
20+
run: yarn run check-prettier

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/dist
2+
/node_modules

LICENSE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2020 Thibault Derousseaux <[email protected]>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# GitHub App Token
2+
3+
This [JavaScript GitHub Action](https://help.github.com/en/actions/building-actions/about-actions#javascript-actions) can be used to impersonate a GitHub App when `secrets.GITHUB_TOKEN`'s limitations are too restrictive and a personal access token is not suitable.
4+
5+
[`secrets.GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) has limitations such as [not being able to triggering a new workflow from another workflow](https://github.community/t5/GitHub-Actions/Triggering-a-new-workflow-from-another-workflow/td-p/31676). A workaround is to use a [personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) from a [personal user/bot account](https://help.github.com/en/github/getting-started-with-github/types-of-github-accounts#personal-user-accounts). However, for organizations, GitHub Apps are [a more appropriate automation solution](https://developer.github.com/apps/differences-between-apps/#machine-vs-bot-accounts).
6+
7+
# Example Workflow
8+
9+
```yml
10+
jobs:
11+
job:
12+
runs-on: ubuntu-18.04
13+
steps:
14+
- name: Generate token
15+
id: generate_token
16+
uses: tibdex/github-app-token@v1
17+
with:
18+
app_id: ${{ secrets.APP_ID }}
19+
private_key: ${{ secrets.PRIVATE_KEY }}
20+
- name: Use token
21+
env:
22+
TOKEN: ${{ steps.generate_token.outputs.token }}
23+
run: |
24+
echo "The generated token is masked: ${TOKEN}"
25+
```

action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: GitHub App token
2+
author: Thibault Derousseaux <[email protected]>
3+
description: Used to impersonate a GitHub App in a GitHub Action when secrets.GITHUB_TOKEN's limitations are too restrictive and a personal access token is not suitable.
4+
inputs:
5+
app_id:
6+
description: ID of the GitHub App.
7+
required: true
8+
private_key:
9+
description: Private key of the GitHub App (can be Base64 encoded).
10+
required: true
11+
outputs:
12+
token:
13+
description: An installation token for the GitHub App on the current repository.
14+
runs:
15+
using: node12
16+
main: dist/index.js
17+
branding:
18+
icon: unlock
19+
color: gray-dark

package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "github-app-token",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"files": [
6+
"action.yml",
7+
"dist"
8+
],
9+
"main": "dist/index.js",
10+
"scripts": {
11+
"build": "ncc build src/index.ts --minify --v8-cache",
12+
"check-prettier": "yarn run prettier --check",
13+
"eslint": "eslint --ignore-path .gitignore --max-warnings 0 \"./**/*.{js,ts}\"",
14+
"format-prettier": "yarn run prettier --write",
15+
"prettier": "prettier --ignore-path .gitignore \"./**/*.{js,json,md,ts,yml}\""
16+
},
17+
"devDependencies": {
18+
"@actions/core": "^1.2.3",
19+
"@actions/github": "^2.1.1",
20+
"@octokit/app": "^4.2.0",
21+
"@types/is-base64": "^1.1.0",
22+
"@types/node": "^10.0.3",
23+
"@typescript-eslint/eslint-plugin": "^2.27.0",
24+
"@typescript-eslint/parser": "^2.27.0",
25+
"@zeit/ncc": "^0.22.1",
26+
"eslint": "^6.8.0",
27+
"eslint-config-prettier": "^6.10.1",
28+
"eslint-config-xo": "^0.29.1",
29+
"eslint-config-xo-typescript": "^0.27.0",
30+
"eslint-import-resolver-typescript": "^2.0.0",
31+
"eslint-plugin-import": "^2.20.2",
32+
"eslint-plugin-sort-destructure-keys": "^1.3.3",
33+
"eslint-plugin-typescript-sort-keys": "^0.8.0",
34+
"eslint-plugin-unicorn": "^18.0.1",
35+
"is-base64": "^1.1.0",
36+
"prettier": "^2.0.4",
37+
"promise-retry": "^1.1.1",
38+
"typescript": "^3.8.3"
39+
}
40+
}

prettier.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use strict";
2+
3+
module.exports = {
4+
trailingComma: "all",
5+
};

0 commit comments

Comments
 (0)