Skip to content

Commit 0d11695

Browse files
committed
refactor: ♻️ add "env_name" input as the exported environment variable name
1 parent 748da26 commit 0d11695

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
app_id: ${{ secrets.APP_ID }}
6262
private_key: ${{ secrets.PRIVATE_KEY }}
6363
# save app's token to the environment variable named "bot_token"
64-
variable_name: bot_token
64+
env_name: bot_token
6565

6666
# Use token in next steps
6767
- uses: 'any other action'
@@ -108,7 +108,7 @@ jobs:
108108
109109
- `app_id`: The ID of the GitHub App. [Create an secret](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets-for-a-repository) named `'APP_ID'` to store your app ID, then used by `${{ secrets.APP_ID }}`
110110
- `private_key`: The private key of the GitHub App (can be Base64 encoded). [Create an secret](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets-for-a-repository) named `'PRIVATE_KEY'` to store your app private key, then used by `${{ secrets.APP_ID }}`
111-
- `variable_name`: The name of generated token in exported variable. Specify a varable name will set an environment variable with specfiied name and valued with generated token, and can be use in next step with `${{ env.variable_name }}`.
111+
- `env_name`: The name of generated token in exported environment variable. Specify a varable name will set an environment variable with specfiied name and valued with generated token, and can be use in next step with `${{ env.env_name }}`.
112112
- `secret_name`: The secret name created on current repository. Specify a secret name will add an secret on current repository with specfiied name and valued with generated token and can be use in next step with `${{ secrets.xxx }}`.
113113
- `clean_secret`: Shoule clean the secret or not when the job completed. Only used when `secret_name` specfiied. Default `false`.
114114

action.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ inputs:
99
description: The private key of the GitHub App (can be Base64 encoded).
1010
required: true
1111
variable_name:
12-
description: The name of generated token in output and exported variable.
12+
description: The name of generated token in exported environment variable.
13+
required: false
14+
env_name:
15+
description: The name of generated token in exported environment variable.
1316
required: false
1417
secret_name:
1518
description: The secret name created on current repository.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "use-app-token",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Run a GitHub Action as a GitHub App to use the app's token.",
55
"main": "dist/index.js",
66
"files": [

src/action.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export namespace Action {
1616
core.setSecret(token)
1717
core.setOutput('token', token)
1818

19-
const variableName = core.getInput('variable_name')
19+
const variableName =
20+
core.getInput('env_name') || core.getInput('variable_name')
2021
if (variableName) {
2122
core.exportVariable(variableName, token)
2223
}

0 commit comments

Comments
 (0)