Skip to content

refactor: improve GitHub API interactions and error handling #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:
- main

permissions:
contents: write
pull-requests: write
contents: write # Required to create tags, creaste releases and update wiki
pull-requests: write # Required to comment on pull requests

jobs:
test-action:
Expand Down
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,27 +124,29 @@ requests and creating releases.
for `pull-requests` must be set to `"write"`.
- Additionally, the workflow permission for `contents` must also be set to `"write"` to allow the action to create tags
and releases.
- For security considerations and best practices when using the `github_token` or PATs, please refer to the
- For security considerations and best practices when using the `github_token`, please refer to the
[Security Documentation](./security.md).
- Ensure the **Restrict editing to users in teams with push access only** setting is enabled for public repositories, as
the GitHub Actions Bot can write to the wiki by default.

If the permissions are insufficient, the action may fail with a 403 error, indicating a lack of access to the necessary
resources.

## Optional Inputs
## Input Parameters

| Input | Description | Default |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------ |
| `major-keywords` | Keywords in commit messages that indicate a major release | `major change,breaking change` |
| `minor-keywords` | Keywords in commit messages that indicate a minor release | `feat,feature` |
| `patch-keywords` | Keywords in commit messages that indicate a patch release | `fix,chore,docs` |
| `default-first-tag` | Specifies the default tag version | `v1.0.0` |
| `github_token` | Use this if you wish to use a different GitHub token than the one provided by the workflow | `${{ github.token }}default` |
| `terraform-docs-version` | Specifies the terraform-docs version used to generate documentation for the wiki | `v0.19.0` |
| `delete-legacy-tags` | Specifies a boolean that determines whether tags from Terraform modules that have been deleted should be automatically removed | `true` |
| `disable-wiki` | Whether to disable wiki generation for Terraform modules | `false` |
| `wiki-sidebar-changelog-max` | An integer that specifies how many changelog entries are displayed in the sidebar per module | `5` |
While the out-of-the-box defaults are suitable for most use cases, you can further customize the action's behavior by
configuring the following optional input parameters as needed.

| Input | Description | Default |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| `major-keywords` | Keywords in commit messages that indicate a major release | `major change,breaking change` |
| `minor-keywords` | Keywords in commit messages that indicate a minor release | `feat,feature` |
| `patch-keywords` | Keywords in commit messages that indicate a patch release | `fix,chore,docs` |
| `default-first-tag` | Specifies the default tag version | `v1.0.0` |
| `terraform-docs-version` | Specifies the terraform-docs version used to generate documentation for the wiki | `v0.19.0` |
| `delete-legacy-tags` | Specifies a boolean that determines whether tags and releases from Terraform modules that have been deleted should be automatically removed | `true` |
| `disable-wiki` | Whether to disable wiki generation for Terraform modules | `false` |
| `wiki-sidebar-changelog-max` | An integer that specifies how many changelog entries are displayed in the sidebar per module | `5` |

### Example Usage with Inputs

Expand Down Expand Up @@ -190,7 +192,8 @@ by Piotr Krukowski.
## Notes

- This action uses [Conventional Commits](https://www.conventionalcommits.org/) to automatically determine the release
type _(major, minor, or patch)_ based on commit messages.
type _(major, minor, or patch)_ based on commit messages. This behavior is configurable via
[inputs](#input-parameters).
- Versioning is done using [Semantic Versioning (SemVer)](https://semver.org/), which provides a clear and consistent
way to manage module versions.
- Commit messages are linked to the respective Terraform directories _(handling PRs that may have separate modules and
Expand Down
11 changes: 6 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ inputs:
description: Specifies the default tag version. (Should be in format v#.#.#)
required: true
default: v1.0.0
github_token:
description: Use this if you wish to use a different GitHub token than the one provided by the workflow.
required: true
default: ${{ github.token }}default
terraform-docs-version:
description: >
Specifies the terraform-docs version used to generate documentation for the wiki.
Expand Down Expand Up @@ -55,7 +51,12 @@ inputs:
Adjust this value to control the visibility of changelog entries in the module sidebar.
required: true
default: "5"

github_token:
description: |
Required for retrieving pull request metadata, tags, releases, updating PR comments, wiki, and creating tags/releases.
Automatically injected for convenience; no need to provide a custom token unless you have specific requirements.
required: true
default: ${{ github.token }}
runs:
using: node20
main: dist/index.js
Loading