Github Action: Make a string lowercase, uppercase, or capitalized
this runs in pure python without any additional packages or dependencies!
- support for UTF-8 strings
- minimal dependencies (small footprint)
- this action has tests to guarantee a smooth experience for you
- using only simple standard python3
- here a list of typical advantages for this approach:
- no dependency on a specific execution environment
- no need to update the action
- less code -> less bugs -> less security issues
- total number of code lines: 14
- no dependency on a specific execution environment
from this project: https://github.com/ASzc/change-string-case-action
This action accepts any string, and outputs three different versions of that string:
- lowercase (
XyZzY
->xyzzy
) - uppercase (
XyZzY
->XYZZY
) - capitalized (
Xyzzy
->Xyzzy
) - dashnormalized (
Xy.ZzY
->xy-zzy
)
You can access the outputted strings through the job outputs context. See docs here, or the Example Usage section below.
Required The string you want manipulated
lowercase="${{ inputs.string }}".lower()
Example: XyZzY
-> xyzzy
uppercase="${{ inputs.string }}".upper()
Example: XyZzY
-> XYZZY
lowercase="${{ inputs.string }}".lower()
uppercase="${{ inputs.string }}".upper()
capitalized=f'{uppercase[:1]}{lowercase[1:]}'
Example: XyZzY
-> Xyzzy
lowercase="${{ inputs.string }}".lower()
dashnormalized=''.join(x if x.isalnum() else '-' for x in lowercase)
Example: Xy.ZzY
-> xy-zzy
name: SomeWorkflow
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- id: string
uses: Entepotenz/change-string-case-action-min-dependencies@v1
with:
string: XyZzY
- id: step2
run: echo ${{ steps.string.outputs.lowercase }}
- id: step3
run: echo ${{ steps.string.outputs.uppercase }}
- id: step4
run: echo ${{ steps.string.outputs.capitalized }}
- id: step5
run: echo ${{ steps.string.outputs.dashnormalized }}