From 29553a27424fd1deb035ede1a3d896ed250bb2a3 Mon Sep 17 00:00:00 2001 From: David Hiendl Date: Sat, 2 Dec 2023 17:26:11 +0100 Subject: [PATCH] test --- action.js | 63 ++---------------------------------------------------- action.yml | 2 ++ 2 files changed, 4 insertions(+), 61 deletions(-) diff --git a/action.js b/action.js index dcf68cb..78e602e 100644 --- a/action.js +++ b/action.js @@ -4,65 +4,6 @@ import * as process from 'process'; import * as semverParser from 'semver-parser'; -try { - const stripTagPrefix = core.getInput('strip_tag_prefix'); +import * as gather from './gather'; - console.log(JSON.stringify(github.context)) - console.log("github.context.ref=" + github.context.ref) - - const isTag = github.context.ref.startsWith("refs/tags/") - core.setOutput("git_is_tag", isTag ? "true" : "false") - - const defaultBranch = github.context.payload?.repository?.defaultBranch - core.setOutput("git_default_branch", defaultBranch) - - const isPullRequest = github.context.payload.pull_request != null - core.setOutput("git_is_pull_request", isPullRequest) - - if(isPullRequest) { - const baseRef = github.context.baseRef || process.env.BODY_REF - const headRef = github.context.payload?.pull_request?.head?.ref || process.env.HEAD_REF - console.log("baseRef=" + baseRef) - console.log("headRef=" + headRef) - - } else if(!isTag) { - if(!github.context.ref.startsWith("refs/heads/")) { - throw new Error("Failed to determine branch for non-PR and non-Tag action") - } - const currentBranch = github.context.ref.slice("refs/heads/".length) - console.log("git_current_branch=" + currentBranch) - core.setOutput("git_current_branch", currentBranch) - - const isDefaultBranch = currentBranch == defaultBranch - console.log("git_current_branch=" + isDefaultBranch ? "true" : "false") - core.setOutput("git_is_default_branch", isDefaultBranch ? "true" : "false") - } - - if(isTag) { - const tag = github.context.ref.slice("refs/tags/".length) - console.log("git_tag=" + tag) - core.setOutput("git_tag", tag) - - const parsed = semverParser.parseSemVer(tag) - console.log("semver=" + JSON.stringify(parsed)) - - core.setOutput("semver_valid", parsed.matches ? "true" : "false") - core.setOutput("semver_major", parsed.major) - core.setOutput("semver_minor", parsed.minor) - core.setOutput("semver_patch", parsed.patch) - core.setOutput("semver_build", parsed.build) - core.setOutput("semver_pre", parsed.pre) - } else { - core.setOutput("git_tag", "false") - core.setOutput("semver_valid", "false") - core.setOutput("semver_major", "false") - core.setOutput("semver_minor", "false") - core.setOutput("semver_patch", "false") - core.setOutput("semver_build", "false") - core.setOutput("semver_pre", "false") - } - - -} catch (error) { - core.setFailed(error.message); -} +gather.gather_information(true, true); \ No newline at end of file diff --git a/action.yml b/action.yml index a36b7b7..3bc728b 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,8 @@ outputs: description: 'Returns `"true"` if the current branch is the default else `"false"`.' git_is_tag: description: 'Returns `"true"` if the current branch is a tag else `"false"`.' + git_is_branch: + description: 'Returns `"true"` if action is executed for a branch (not Tag, not PR), else `"false"`.' git_default_branch: description: 'The default branch name e.g `main` OR `master`' git_current_branch: