https://github.com/marcransome/remove-ansi-colors
A GitHub action for removing ANSI color escape sequences from arbitrary strings.
https://github.com/marcransome/remove-ansi-colors
ansi-colors ansi-escape-codes github-actions
Last synced: 5 months ago
JSON representation
A GitHub action for removing ANSI color escape sequences from arbitrary strings.
- Host: GitHub
- URL: https://github.com/marcransome/remove-ansi-colors
- Owner: marcransome
- License: mit
- Created: 2021-09-08T17:35:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-06T17:16:35.000Z (6 months ago)
- Last Synced: 2024-11-06T18:25:52.417Z (6 months ago)
- Topics: ansi-colors, ansi-escape-codes, github-actions
- Homepage:
- Size: 270 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# remove-ansi-colors
[](https://securityscorecards.dev/viewer/?uri=github.com/marcransome/remove-ansi-colors) [](https://github.com/marcransome/remove-ansi-colors/actions) [](https://github.com/marcransome/remove-ansi-colors/issues/) [](https://github.com/marcransome/remove-ansi-colors/network/dependencies) [](https://opensource.org/licenses/mit-license.php)
A GitHub action for removing ANSI color escape sequences from arbitrary strings.
## Prerequisites
This action has a few dependencies that are generally satisfied by most [GitHub-hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners) (`macos-*` and `ubuntu-*` environment variants):
* [GNU Bash](https://www.gnu.org/software/bash/)
* [Perl](https://www.perl.org)## Usage
Add a suitable `uses` step to your GitHub [workflow](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions) with a value for the `colored` step input (i.e. an output from a previous step that includes ANSI color escape sequences) and use the `uncolored` output in subsequent steps:
```yaml
jobs:
remove-ansi-colors:
runs-on: ubuntu-latest
steps:
- name: A step that generates output with ANSI color escape sequences
id: generate-colored-output
run: |
colored=$(printf '\e[0;31mCOLORED\e[0m')
echo "colored=$colored" >> "$GITHUB_OUTPUT"
- name: Remove ANSI color escape sequences
uses: marcransome/remove-ansi-colors@v1
id: remove-ansi-colors
with:
colored: ${{ steps.generate-colored-output.outputs.colored }}
- name: Use uncolored output
run: echo "${{ steps.remove-ansi-colors.outputs.uncolored }}"
```## Inputs
* `colored` - A string containing ANSI color escape sequences.
## Outputs
* `uncolored` - The `colored` input string with ANSI color escape sequences removed.
## Action versions
Use one of the following patterns when specifying the version reference for this action in your workflow (i.e. the `{ref}` value in `uses: marcransome/remove-ansi-colors@{ref}`):
| Pattern | Example | Description |
|----------|-----------|------------------------------------------------------------------------|
| `vX` | `v1` | the latest `v1.*` release including non-breaking changes and bug fixes |
| `vX.Y` | `v1.1` | the latest `v1.1.*` release including bug fixes |
| `vX.Y.Z` | `v1.1.0` | the `v1.1.0` release only |The recommended pattern when using tags is `vX` (e.g. `v1`). This will ensure that the version of the action used in your workflow includes the latest non-breaking changes and bug fixes, and guarantees compatibility with previous versions of that major release number.
>[!TIP]
>
> For improved security, pin the action to a full length commit SHA rather than a tag version and [use Dependabot version updates to keep the action up to date](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-dependabot-version-updates-to-keep-actions-up-to-date). For example:
>
> ```yaml
> uses: marcransome/remove-ansi-colors@88e03a4ec5e23f3d97e93c76051c1cd7d4389881 # v1.4.1
> ```Using a `main` branch reference in your workflow is _not_ recommended as this branch may include breaking changes intended for the next major release.
## Acknowledgements
* Paint roller icon made by [Freepik](https://www.flaticon.com/authors/freepik) from [www.flaticon.com](https://www.flaticon.com/)
## License
`remove-ansi-colors` is provided under the terms of the [MIT License](https://opensource.org/licenses/mit-license.php).## Contact
Email me at [[email protected]](mailto:[email protected]) or [create an issue](https://github.com/marcransome/remove-ansi-colors/issues).