Skip to content

Commit

Permalink
refactor: ♻️ add "env_name" input as the exported environment variabl…
Browse files Browse the repository at this point in the history
…e name
  • Loading branch information
bubkoo committed Oct 29, 2020
1 parent 748da26 commit 0d11695
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
# save app's token to the environment variable named "bot_token"
variable_name: bot_token
env_name: bot_token

# Use token in next steps
- uses: 'any other action'
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
- `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 }}`
- `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 }}`
- `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 }}`.
- `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 }}`.
- `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 }}`.
- `clean_secret`: Shoule clean the secret or not when the job completed. Only used when `secret_name` specfiied. Default `false`.

Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ inputs:
description: The private key of the GitHub App (can be Base64 encoded).
required: true
variable_name:
description: The name of generated token in output and exported variable.
description: The name of generated token in exported environment variable.
required: false
env_name:
description: The name of generated token in exported environment variable.
required: false
secret_name:
description: The secret name created on current repository.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "use-app-token",
"version": "1.1.0",
"version": "1.1.1",
"description": "Run a GitHub Action as a GitHub App to use the app's token.",
"main": "dist/index.js",
"files": [
Expand Down
3 changes: 2 additions & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export namespace Action {
core.setSecret(token)
core.setOutput('token', token)

const variableName = core.getInput('variable_name')
const variableName =
core.getInput('env_name') || core.getInput('variable_name')
if (variableName) {
core.exportVariable(variableName, token)
}
Expand Down

0 comments on commit 0d11695

Please sign in to comment.