-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
257 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
__tests__/runner/* | ||
|
||
node_modules/ | ||
|
||
.idea/ | ||
|
||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,41 @@ | ||
console.log("test"); | ||
const core = require('@actions/core'); | ||
|
||
try { | ||
// `body`, `splitStr`, `splitIndex`, `replaceBefore`, `replaceAfter`, `envName` 입력값 가져오기 | ||
const body = core.getInput('body', { required: true }); | ||
const splitStr = core.getInput('split', { required: false }); | ||
const splitIndex = splitStr ? parseInt(core.getInput('splitIndex', { required: true }), 10) : null; | ||
const replaceBefore = core.getInput('replaceBefore', { required: false }); | ||
const replaceAfter = core.getInput('replaceAfter', { required: false }); | ||
const envName = core.getInput('envName', { required: true }); | ||
|
||
// splitStr이 있는 경우, splitIndex가 존재해야 함 | ||
if (splitStr && splitIndex === null) { | ||
throw new Error('splitStr이 주어졌을 경우, splitIndex도 필수입니다.'); | ||
} | ||
|
||
// 문자열 처리 | ||
let result = body; | ||
|
||
// split 처리 | ||
if (splitStr) { | ||
const splitResult = result.split(splitStr); | ||
if (splitIndex >= splitResult.length || splitIndex < 0) { | ||
throw new Error(`Invalid splitIndex: ${splitIndex}. It should be between 0 and ${splitResult.length - 1}.`); | ||
} | ||
result = splitResult[splitIndex]; | ||
} | ||
|
||
// replaceBefore 및 replaceAfter 처리 | ||
if (replaceBefore && replaceAfter) { | ||
const regex = new RegExp(replaceBefore, 'g'); | ||
result = result.replace(regex, replaceAfter); | ||
} | ||
|
||
// 결과를 `GITHUB_ENV`에 저장 | ||
core.exportVariable(envName, result); | ||
|
||
console.log(`Parsed Result: ${result}`); | ||
} catch (error) { | ||
core.setFailed(`Error: ${error.message}`); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "string-parser", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@actions/core": "^1.11.1" | ||
} | ||
} |