@@ -6,44 +6,78 @@ This GitHub Action can be used to impersonate a GitHub App when `secrets.GITHUB_
6
6
7
7
We can also use an app token to [ custom an action's name and avatar] ( https://github.community/t/change-bots-name-avatar/18349 ) .
8
8
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 )
10
10
11
11
## Usage
12
12
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.
14
32
15
33
``` yml
16
- name : Needs More Info
17
- on :
18
- pull_request :
19
- types : [opened]
20
- issues :
21
- types : [opened]
22
34
jobs :
23
35
run :
24
36
runs-on : ubuntu-latest
25
37
steps :
26
- - name : Generate token
38
+ - uses : bubkoo/use-app- token@v1
27
39
id : generate_token
28
- uses : bubkoo/use-app-token@v1
29
40
with :
30
41
app_id : ${{ secrets.APP_ID }}
31
42
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'
34
46
with :
35
- # Use token in outpus of the 'generate_token' action
47
+ # Use token in outpus of the 'generate_token' step
36
48
GITHUB_TOKEN : ${{ steps.generate_token.outputs.token }}
37
- CONFIG_FILE : .github/workflows/config/needs-more-info.yml
38
49
` ` `
39
50
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.
41
74
42
75
` ` ` yml
43
- name : App Token
76
+ name : Use App Token
44
77
on :
45
78
schedule :
46
- - cron : ' 0 1 * * *'
79
+ # add or update secret every hour
80
+ - cron : ' 0 */1 * * *'
47
81
jobs :
48
82
run :
49
83
runs-on : ubuntu-latest
@@ -53,27 +87,19 @@ jobs:
53
87
app_id : ${{ secrets.APP_ID }}
54
88
private_key : ${{ secrets.PRIVATE_KEY }}
55
89
# The secret name
56
- secret_name : APP_TOKEN
90
+ secret_name : BOT_TOKEN
57
91
` ` `
58
92
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.
60
94
61
95
` ` ` yml
62
- name : Needs More Info
63
- on :
64
- pull_request :
65
- types : [opened]
66
- issues :
67
- types : [opened]
68
96
jobs :
69
97
run :
70
98
runs-on : ubuntu-latest
71
99
steps :
72
- - name : Needs More info
73
- uses : bubkoo/needs-more-info@v1
100
+ - uses : ' any other action'
74
101
with :
75
- GITHUB_TOKEN : ${{ secrets.APP_TOKEN }}
76
- CONFIG_FILE : .github/workflows/config/needs-more-info.yml
102
+ GITHUB_TOKEN : ${{ secrets.BOT_TOKEN }}
77
103
` ` `
78
104
79
105
### Inputs
0 commit comments