From 0d48f8bccb8cd709fac2b54bc754bad73be3fc38 Mon Sep 17 00:00:00 2001 From: Xavier Krantz Date: Tue, 24 Dec 2024 17:55:55 +0100 Subject: [PATCH 1/6] Update repo.ts Signed-off-by: Xavier Krantz --- src/github/repo.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/github/repo.ts b/src/github/repo.ts index b54e7c3..bf743bf 100644 --- a/src/github/repo.ts +++ b/src/github/repo.ts @@ -6,6 +6,14 @@ function resolveCurrentBranch(ref: string): string { } else if (ref.startsWith('refs/pull/')) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access return github.context.payload.pull_request?.head?.ref ?? '' + } else if (ref.startsWith('refs/tags/') { + // Get the repository default branch + const octokit = github.getOctokit(github.context.token) + const { data: default_branch } = await octokit.rest.repos.get({ + github.context.repository.split('/')[0], + github.context.repository.split('/')[1], + }); + return default_branch; } throw new Error(`Unsupported ref: ${ref}`) From d218af6a425e202222d3fa71b4e18ddf6cfee70a Mon Sep 17 00:00:00 2001 From: Stessy Mougeot Date: Mon, 30 Dec 2024 10:07:24 +0100 Subject: [PATCH 2/6] fix: missing ) --- src/github/repo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/repo.ts b/src/github/repo.ts index bf743bf..1f496d3 100644 --- a/src/github/repo.ts +++ b/src/github/repo.ts @@ -6,7 +6,7 @@ function resolveCurrentBranch(ref: string): string { } else if (ref.startsWith('refs/pull/')) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access return github.context.payload.pull_request?.head?.ref ?? '' - } else if (ref.startsWith('refs/tags/') { + } else if (ref.startsWith('refs/tags/')) { // Get the repository default branch const octokit = github.getOctokit(github.context.token) const { data: default_branch } = await octokit.rest.repos.get({ From ac706b90c259fb6ff1b9265ecf3da693b9342dde Mon Sep 17 00:00:00 2001 From: Stessy Mougeot Date: Mon, 30 Dec 2024 11:11:38 +0100 Subject: [PATCH 3/6] update repo.ts --- src/github/repo.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/github/repo.ts b/src/github/repo.ts index 1f496d3..212f377 100644 --- a/src/github/repo.ts +++ b/src/github/repo.ts @@ -7,13 +7,8 @@ function resolveCurrentBranch(ref: string): string { // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access return github.context.payload.pull_request?.head?.ref ?? '' } else if (ref.startsWith('refs/tags/')) { - // Get the repository default branch - const octokit = github.getOctokit(github.context.token) - const { data: default_branch } = await octokit.rest.repos.get({ - github.context.repository.split('/')[0], - github.context.repository.split('/')[1], - }); - return default_branch; + // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access + return github.context.payload.repo.default_branch ?? '' } throw new Error(`Unsupported ref: ${ref}`) From f209110809ab94fc969fe288c2440925eb07d135 Mon Sep 17 00:00:00 2001 From: Stessy Mougeot Date: Mon, 30 Dec 2024 11:59:56 +0100 Subject: [PATCH 4/6] fixup: build dist --- dist/index.js | 174 +++++++++++++++++++++++++++++++++------------- package-lock.json | 23 +++--- package.json | 2 +- 3 files changed, 138 insertions(+), 61 deletions(-) diff --git a/dist/index.js b/dist/index.js index d0daefb..8d5f117 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29825,13 +29825,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( }) : function(o, v) { o["default"] = v; }); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -29959,13 +29969,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( }) : function(o, v) { o["default"] = v; }); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -30137,13 +30157,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( }) : function(o, v) { o["default"] = v; }); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -30314,18 +30344,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( }) : function(o, v) { o["default"] = v; }); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getContext = getContext; const github = __importStar(__nccwpck_require__(3228)); function resolveCurrentBranch(ref) { - var _a, _b, _c; + var _a, _b, _c, _d; if (ref.startsWith('refs/heads/')) { return ref.replace(/refs\/heads\//g, ''); } @@ -30333,6 +30373,10 @@ function resolveCurrentBranch(ref) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access return (_c = (_b = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head) === null || _b === void 0 ? void 0 : _b.ref) !== null && _c !== void 0 ? _c : ''; } + else if (ref.startsWith('refs/tags/')) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access + return (_d = github.context.payload.repo.default_branch) !== null && _d !== void 0 ? _d : ''; + } throw new Error(`Unsupported ref: ${ref}`); } function getContext() { @@ -30367,13 +30411,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( }) : function(o, v) { o["default"] = v; }); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -30586,13 +30640,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( }) : function(o, v) { o["default"] = v; }); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getCwd = getCwd; exports.getWorkspace = getWorkspace; @@ -30642,13 +30706,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( }) : function(o, v) { o["default"] = v; }); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getInput = getInput; const core = __importStar(__nccwpck_require__(7484)); diff --git a/package-lock.json b/package-lock.json index 08fc7d1..32bdad5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "fetch-mock": "^11.1.5", "jest": "^29.0.0", "ts-jest": "^29.2.5", - "typescript": "^5.6.2", + "typescript": "^5.7.2", "typescript-eslint": "^8.11.0" }, "engines": { @@ -717,10 +717,11 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.0.tgz", - "integrity": "sha512-vH9PiIMMwvhCx31Af3HiGzsVNULDbyVkHXwlemn/B0TFj/00ho3y55efXrUZTfQipxoHC5u4xq6zblww1zm1Ig==", + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.4.tgz", + "integrity": "sha512-zSkKow6H5Kdm0ZUQUB2kV5JIXqoG0+uH5YADhaEHswm664N9Db8dXSi0nMJpacpMf+MyyglF1vnZohpEg5yUtg==", "dev": true, + "license": "Apache-2.0", "dependencies": { "levn": "^0.4.1" }, @@ -2395,10 +2396,11 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -5527,10 +5529,11 @@ } }, "node_modules/typescript": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", - "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 42a7344..c0d110b 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "fetch-mock": "^11.1.5", "jest": "^29.0.0", "ts-jest": "^29.2.5", - "typescript": "^5.6.2", + "typescript": "^5.7.2", "typescript-eslint": "^8.11.0" }, "engines": { From 5b1e1f1a850b4b290b3528917a88739b5a68867a Mon Sep 17 00:00:00 2001 From: Stessy Mougeot Date: Mon, 6 Jan 2025 15:09:55 +0100 Subject: [PATCH 5/6] fix: return "" on tags --- dist/index.js | 5 ++--- src/github/repo.ts | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dist/index.js b/dist/index.js index 8d5f117..0214021 100644 --- a/dist/index.js +++ b/dist/index.js @@ -30365,7 +30365,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getContext = getContext; const github = __importStar(__nccwpck_require__(3228)); function resolveCurrentBranch(ref) { - var _a, _b, _c, _d; + var _a, _b, _c; if (ref.startsWith('refs/heads/')) { return ref.replace(/refs\/heads\//g, ''); } @@ -30374,8 +30374,7 @@ function resolveCurrentBranch(ref) { return (_c = (_b = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head) === null || _b === void 0 ? void 0 : _b.ref) !== null && _c !== void 0 ? _c : ''; } else if (ref.startsWith('refs/tags/')) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access - return (_d = github.context.payload.repo.default_branch) !== null && _d !== void 0 ? _d : ''; + return ''; } throw new Error(`Unsupported ref: ${ref}`); } diff --git a/src/github/repo.ts b/src/github/repo.ts index 212f377..4ab9b8f 100644 --- a/src/github/repo.ts +++ b/src/github/repo.ts @@ -7,8 +7,7 @@ function resolveCurrentBranch(ref: string): string { // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access return github.context.payload.pull_request?.head?.ref ?? '' } else if (ref.startsWith('refs/tags/')) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access - return github.context.payload.repo.default_branch ?? '' + return '' } throw new Error(`Unsupported ref: ${ref}`) From 9d2525229a0188faf50aab3502d815a34c71e2cf Mon Sep 17 00:00:00 2001 From: Stessy Mougeot Date: Mon, 6 Jan 2025 17:11:45 +0100 Subject: [PATCH 6/6] chore(readme): Update inputs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5b1125e..9ed0b2c 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request | `files` | **YES** | Multi-line string of file paths to be committed, relative to the current workspace.| | `workspace` | **NO** | Directory containing files to be committed. **DEFAULT:** GitHub workspace directory (root of the repository). | | `commit-message` | **YES** | Commit message for the file changes. | -| `branch-name` | **NO** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch | +| `branch-name` | **NO*** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch. **REQUIRED:** If triggered through `on tags`.| | `branch-push-force` | **NO** | `--force` flag when running `git push `. | | `tag` | **NO** | Push tag for the new/current commit. | | `tag-only-if-file-changes` | **NO** | Push tag for new commit only when file changes present. **DEFAULT:** true | @@ -79,4 +79,4 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request [coverage_badge]: https://codecov.io/gh/ryancyq/github-signed-commit/graph/badge.svg?token=KZTD2F2MN2 [coverage]: https://codecov.io/gh/ryancyq/github-signed-commit [maintainability_badge]: https://api.codeclimate.com/v1/badges/0de9dbec270ca85719c6/maintainability -[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability \ No newline at end of file +[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability