Skip to content

Commit 7b9b891

Browse files
authored
fix: Add --repo option in order to correctly detect repository to add secret to (#3)
* fix: Add --repo option in order to correctly detect repository to add secret to * docs: Automated README update * docs: Update README with info about commits and repo secrets permissions * docs: Update github_token description * docs: Automated README update
1 parent 6517efa commit 7b9b891

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Rotates a HCP Terraform user token stored as a secret in a GitHub repository.
99

1010
| name | description | required | default |
1111
| --- | --- | --- | --- |
12-
| `github_token` | <p>GitHub token used for writing the HCP Terraform user token to the repository secret store.</p> | `false` | `${{ github.token }}` |
12+
| `github_token` | <p>GitHub token used for writing the HCP Terraform user token to the repository secret store. Requires the repository permission secrets:write.</p> | `true` | `""` |
1313
| `github_secrets_name` | <p>Name of the secret in the repository secret store where the token will be written.</p> | `false` | `HCP_TERRAFORM_USER_TOKEN` |
1414
| `hcp_terraform_user_token` | <p>HCP Terraform user token to be rotated. This token must already exist and be saved as a repository secret before running this action.</p> | `true` | `""` |
1515
| `hcp_terraform_user_token_description` | <p>Description for the HCP Terraform user token. Must be the same for the original and new tokens.</p> | `false` | `github-token` |
@@ -26,10 +26,10 @@ This action is a `composite` action.
2626
- uses: bendwyer/action-rotate-hcp-terraform-user-token@v1
2727
with:
2828
github_token:
29-
# GitHub token used for writing the HCP Terraform user token to the repository secret store.
29+
# GitHub token used for writing the HCP Terraform user token to the repository secret store. Requires the repository permission secrets:write.
3030
#
31-
# Required: false
32-
# Default: ${{ github.token }}
31+
# Required: true
32+
# Default: ""
3333

3434
github_secrets_name:
3535
# Name of the secret in the repository secret store where the token will be written.
@@ -57,7 +57,22 @@ This action is a `composite` action.
5757
```
5858
<!-- action-docs-all source="action.yml" project="bendwyer/action-rotate-hcp-terraform-user-token" version="v1" -->
5959

60+
Commits
61+
-------
62+
63+
[Commit headers](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit-header) are expected in order for version bumping to work correctly:
64+
65+
- **build**: Changes that affect the build system or external dependencies
66+
- **ci**: Changes to CI configuration files and scripts
67+
- **docs**: Documentation only changes
68+
- **feat**: A new feature
69+
- **fix**: A bug fix
70+
- **perf**: A code change that improves performance
71+
- **refactor**: A code change that neither fixes a bug nor adds a feature
72+
- **test**: Adding missing tests or correcting existing tests
73+
6074
Resources
6175
---------
6276

6377
- [Changing Passwords and Updating Tokens Outside of the Terraform Cloud and Terraform Enterprise UI](https://support.hashicorp.com/hc/en-us/articles/4402342106003-Changing-Passwords-and-Updating-Tokens-Outside-of-the-Terraform-Cloud-and-Terraform-Enterprise-UI)
78+
- [Create or update a repository secret](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret)

action.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ author: Ben Dwyer (github.com/bendwyer)
55

66
inputs:
77
github_token:
8-
description: GitHub token used for writing the HCP Terraform user token to the repository secret store.
9-
required: false
10-
default: ${{ github.token }}
8+
description: "GitHub token used for writing the HCP Terraform user token to the repository secret store. Requires the repository permission secrets:write."
9+
required: true
1110
github_secrets_name:
1211
description: Name of the secret in the repository secret store where the token will be written.
1312
required: false
@@ -86,7 +85,7 @@ runs:
8685
echo "Mask new token"
8786
echo "::add-mask::$NEW_TOKEN"
8887
echo "Write new token to repository secrets"
89-
gh secret set $SECRETS_NAME --body "$NEW_TOKEN" --app actions
88+
gh secret set $SECRETS_NAME --body "$NEW_TOKEN" --repo ${{ github.repository }} --app actions
9089
fi
9190
echo "Check if old user token should be deleted"
9291
if [[ $MATCHED_TOKEN_COUNT == 1 ]]

0 commit comments

Comments
 (0)