Skip to content

Commit 748da26

Browse files
committed
docs: πŸ“šοΈ config action
1 parent 7488fcc commit 748da26

File tree

5 files changed

+55
-29
lines changed

5 files changed

+55
-29
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,78 @@ This GitHub Action can be used to impersonate a GitHub App when `secrets.GITHUB_
66

77
We can also use an app token to [custom an action's name and avatar](https://github.community/t/change-bots-name-avatar/18349).
88

9-
![all links](https://github.com/bubkoo/use-app-token/blob/master/screenshot.jpg?raw=true)
9+
![screenshot](https://github.com/bubkoo/use-app-token/blob/master/screenshots/screenshot.jpg?raw=true)
1010

1111
## Usage
1212

13-
Use action's output in other actions.
13+
Before staring, we should get our owned app's _"APP ID"_ and _"Private Key"_ in the app's setting page. For example, find the two values in my app's setting page [https://github.com/settings/apps/bubkoo-bot](https://github.com/settings/apps/bubkoo-bot).
14+
15+
Get your owned app's _"APP ID"_:
16+
17+
![get-app-id](https://github.com/bubkoo/use-app-token/blob/master/screenshots/get-app-id.jpg?raw=true)
18+
19+
Get or create a _"Private Key"_:
20+
21+
![get-private-key](https://github.com/bubkoo/use-app-token/blob/master/screenshots/get-private-key.jpg?raw=true)
22+
23+
**Do not have a Github App? Get a quick start with [probot](https://probot.github.io/).**
24+
25+
Then add _"APP ID"_ and _"Private Key"_ to the target [repo's secrets](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets). For example, we can add two secrets named `APP_ID` and `PRIVATE_KEY` with corresponding value.
26+
27+
![secrets](https://github.com/bubkoo/use-app-token/blob/master/screenshots/secrets.jpg?raw=true)
28+
29+
Now we can config the action by three ways:
30+
31+
**Method 1**: Use action's output in the next steps.
1432

1533
```yml
16-
name: Needs More Info
17-
on:
18-
pull_request:
19-
types: [opened]
20-
issues:
21-
types: [opened]
2234
jobs:
2335
run:
2436
runs-on: ubuntu-latest
2537
steps:
26-
- name: Generate token
38+
- uses: bubkoo/use-app-token@v1
2739
id: generate_token
28-
uses: bubkoo/use-app-token@v1
2940
with:
3041
app_id: ${{ secrets.APP_ID }}
3142
private_key: ${{ secrets.PRIVATE_KEY }}
32-
- name: Needs More info # Use token in other actions
33-
uses: bubkoo/needs-more-info@v1
43+
44+
# Use token in next steps
45+
- uses: 'any other action'
3446
with:
35-
# Use token in outpus of the 'generate_token' action
47+
# Use token in outpus of the 'generate_token' step
3648
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
37-
CONFIG_FILE: .github/workflows/config/needs-more-info.yml
3849
```
3950
40-
Or set an secret in you repo:
51+
**Method 2**: Set an environment variable and used in the next step.
52+
53+
```yml
54+
jobs:
55+
run:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: bubkoo/use-app-token@v1
59+
id: generate_token
60+
with:
61+
app_id: ${{ secrets.APP_ID }}
62+
private_key: ${{ secrets.PRIVATE_KEY }}
63+
# save app's token to the environment variable named "bot_token"
64+
variable_name: bot_token
65+
66+
# Use token in next steps
67+
- uses: 'any other action'
68+
with:
69+
# Use token in the environment variable named "bot_token"
70+
GITHUB_TOKEN: ${{ env.bot_token }}
71+
```
72+
73+
**Method 3**: Add or update an secret in the target repo schedulely.
4174
4275
```yml
43-
name: App Token
76+
name: Use App Token
4477
on:
4578
schedule:
46-
- cron: '0 1 * * *'
79+
# add or update secret every hour
80+
- cron: '0 */1 * * *'
4781
jobs:
4882
run:
4983
runs-on: ubuntu-latest
@@ -53,27 +87,19 @@ jobs:
5387
app_id: ${{ secrets.APP_ID }}
5488
private_key: ${{ secrets.PRIVATE_KEY }}
5589
# The secret name
56-
secret_name: APP_TOKEN
90+
secret_name: BOT_TOKEN
5791
```
5892
59-
Then we can use the secret named `'APP_TOKEN'` in other ancitons:
93+
Then we can use the secret named `'BOT_TOKEN'` in the next steps.
6094
6195
```yml
62-
name: Needs More Info
63-
on:
64-
pull_request:
65-
types: [opened]
66-
issues:
67-
types: [opened]
6896
jobs:
6997
run:
7098
runs-on: ubuntu-latest
7199
steps:
72-
- name: Needs More info
73-
uses: bubkoo/needs-more-info@v1
100+
- uses: 'any other action'
74101
with:
75-
GITHUB_TOKEN: ${{ secrets.APP_TOKEN }}
76-
CONFIG_FILE: .github/workflows/config/needs-more-info.yml
102+
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
77103
```
78104
79105
### Inputs

β€Žscreenshots/get-app-id.jpgβ€Ž

149 KB
Loading
64.3 KB
Loading
File renamed without changes.

β€Žscreenshots/secrets.jpgβ€Ž

210 KB
Loading

0 commit comments

Comments
Β (0)