From 037d5ffb0c41c2aefdf821b3540b03c64287da45 Mon Sep 17 00:00:00 2001 From: Yurii Dukhovnyi Date: Wed, 18 Oct 2023 16:16:24 +0300 Subject: [PATCH] ts->js --- .../deployment-action/deployment-action.js | 22 +++++++++++-------- .../deployment-action/deployment-action.ts | 14 ++++++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 .github/actions/deployment-action/deployment-action.ts diff --git a/.github/actions/deployment-action/deployment-action.js b/.github/actions/deployment-action/deployment-action.js index f142220b6..92be97856 100644 --- a/.github/actions/deployment-action/deployment-action.js +++ b/.github/actions/deployment-action/deployment-action.js @@ -1,12 +1,16 @@ -const core = require('@actions/core'); -const github = require('@actions/github'); - +"use strict"; +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +var core = require("@actions/core"); +var github = require("@actions/github"); try { - const branchName = core.getInput("branch-name"); - console.log(`The branch name is "${branchName}" from param.`); - - const ref = github.context.payload.pull_request["head"]["ref"] + var ref = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a["head"]["ref"]; console.log(ref); -} catch(error) { + if (ref == 'master' || (ref === null || ref === void 0 ? void 0 : ref.startsWith('release')) == true) { } + else { + core.setFailed("'".concat(ref, "' branch can't be released. Only 'master' or 'release/*' branches can be released.")); + } +} +catch (error) { core.setFailed(error.message); -} \ No newline at end of file +} diff --git a/.github/actions/deployment-action/deployment-action.ts b/.github/actions/deployment-action/deployment-action.ts new file mode 100644 index 000000000..a09d985e6 --- /dev/null +++ b/.github/actions/deployment-action/deployment-action.ts @@ -0,0 +1,14 @@ +import * as core from '@actions/core'; +import * as github from '@actions/github'; + +try { + const ref = github.context.payload.pull_request?.["head"]["ref"] as string | null | undefined; + console.log(ref); + + if (ref == 'master' || ref?.startsWith('release') == true) {} else { + core.setFailed(`'${ref}' branch can't be released. Only 'master' or 'release/*' branches can be released.`); + core.setOutput(`'${ref}' branch can't be released. Only 'master' or 'release/*' branches can be released.`, 'forbidden'); + } +} catch(error) { + core.setFailed(error.message); +} \ No newline at end of file