Skip to content

IJop148/ActionStringFormatter

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

change-string-case-action-min-dependencies

Github Action: Make a string lowercase, uppercase, or capitalized

this runs in pure python without any additional packages or dependencies!

Change String Case GitHub 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.

Inputs

string

Required The string you want manipulated

Outputs

lowercase

lowercase="${{ inputs.string }}".lower()

Example: XyZzY -> xyzzy

uppercase

uppercase="${{ inputs.string }}".upper()

Example: XyZzY -> XYZZY

capitalized

lowercase="${{ inputs.string }}".lower()
uppercase="${{ inputs.string }}".upper()
capitalized=f'{uppercase[:1]}{lowercase[1:]}'

Example: XyZzY -> Xyzzy

dashnormalized

lowercase="${{ inputs.string }}".lower()
dashnormalized=''.join(x if x.isalnum() else '-' for x in lowercase)

Example: Xy.ZzY -> xy-zzy

afterlastdash

afterlastdash="${{ inputs.string }}".split("/")[-1]

lowerlastdash

lowerlastdash="${{ inputs.string }}".split("/")[-1].lower()

Example Usage

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 }}
      - id: step6
        run: echo ${{ steps.string.outputs.afterlastdash }}
      - id: step7
        run: echo ${{ steps.string.outputs.lowerlastdash }}

About

Github Action: Make a string lowercase, uppercase, or capitalized; done with minimal dependencies

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%