├── .gitignore ├── package.json ├── LICENSE ├── action.yml ├── index.js └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "change-string-case-action", 3 | "version": "1.0.0", 4 | "description": "String case manipulation action for Github", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "Alex Szczuczko", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@actions/core": "^1.10.1", 14 | "@actions/github": "^6.0.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Alex Szczuczko 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 6 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Change String Case 2 | author: Alex Szczuczko 3 | description: Make a string lowercase, uppercase, or capitalized 4 | branding: 5 | icon: corner-down-right 6 | color: gray-dark 7 | inputs: 8 | string: 9 | description: The input string 10 | required: true 11 | outputs: 12 | lowercase: 13 | description: The input string, with any uppercase characters replaced with lowercase ones 14 | uppercase: 15 | description: The input string, with any lowercase characters replaced with uppercase ones 16 | capitalized: 17 | description: The input string, with any alphabetical characters lowercase, except for the first character, which is uppercased 18 | runs: 19 | using: node20 20 | main: index.js 21 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const core = require('@actions/core'); 2 | const github = require('@actions/github'); 3 | 4 | try { 5 | const inputStr = core.getInput('string'); 6 | console.log(`Manipulating string: ${inputStr}`); 7 | 8 | const lowercase = inputStr.toLowerCase(); 9 | console.log(`lowercase: ${lowercase}`); 10 | core.setOutput("lowercase", lowercase); 11 | 12 | const uppercase = inputStr.toUpperCase(); 13 | console.log(`uppercase: ${uppercase}`); 14 | core.setOutput("uppercase", uppercase); 15 | 16 | const capitalized = inputStr.charAt(0).toUpperCase() + inputStr.slice(1).toLowerCase(); 17 | console.log(`capitalized: ${capitalized}`); 18 | core.setOutput("capitalized", capitalized); 19 | } catch (error) { 20 | core.setFailed(error.message); 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Change String Case GitHub Action 2 | 3 | This action accepts any string, and outputs three different versions of that string: 4 | 5 | - lowercase (`XyZzY` -> `xyzzy`) 6 | - uppercase (`XyZzY` -> `XYZZY`) 7 | - capitalized (`Xyzzy` -> `Xyzzy`) 8 | 9 | You can access the outputted strings through the job outputs context. See docs [here](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjobs_idoutputs), or the Example Usage section below. 10 | 11 | ## Inputs 12 | 13 | ### `string` 14 | 15 | **Required** The string you want manipulated 16 | 17 | ## Outputs 18 | 19 | ### `lowercase` 20 | 21 | `inputStr.toLowerCase()` 22 | 23 | Example: `XyZzY` -> `xyzzy` 24 | 25 | ### `uppercase` 26 | 27 | `inputStr.toUpperCase()` 28 | 29 | Example: `XyZzY` -> `XYZZY` 30 | 31 | ### `capitalized` 32 | 33 | `inputStr.charAt(0).toUpperCase() + inputStr.slice(1).toLowerCase()` 34 | 35 | Example: `XyZzY` -> `Xyzzy` 36 | 37 | ## Example Usage 38 | 39 | ```yaml 40 | name: SomeWorkflow 41 | on: [push] 42 | jobs: 43 | build: 44 | name: Build 45 | runs-on: ubuntu-latest 46 | steps: 47 | - id: string 48 | uses: ASzc/change-string-case-action@v6 49 | with: 50 | string: XyZzY 51 | - id: step2 52 | run: echo ${{ steps.string.outputs.lowercase }} 53 | ``` 54 | --------------------------------------------------------------------------------