Skip to content

Commit 5d85f5f

Browse files
xakrazStessyMougeot
andcommitted
feat: Add support for Tags push events (#3)
* Update repo.ts Signed-off-by: Xavier Krantz <xavier.krantz@datadome.co> * fix: missing ) * update repo.ts * fixup: build dist * fix: return "" on tags * chore(readme): Update inputs --------- Signed-off-by: Xavier Krantz <xavier.krantz@datadome.co> Co-authored-by: Stessy Mougeot <stessy.mougeot@icloud.com>
1 parent ecb196e commit 5d85f5f

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
6363
| `files` | **YES** | Multi-line string of file paths to be committed, relative to the current workspace.|
6464
| `workspace` | **NO** | Directory containing files to be committed. **DEFAULT:** GitHub workspace directory (root of the repository). |
6565
| `commit-message` | **YES** | Commit message for the file changes. |
66-
| `repository` | **NO** | Repository name including owner (e.g. owner/repo). **DEFAULT:** Workflow triggered repository |
67-
| `branch-name` | **NO** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch |
66+
| `owner` | **NO** | GitHub repository owner (user or organization), defaults to the repo invoking the action. |
67+
| `repo` | **NO** | GitHub repository name, defaults to the repo invoking the action. |
68+
| `branch-name` | **NO*** | Branch to commit, it must already exist in the remote. **DEFAULT:** Workflow triggered branch. **REQUIRED:** If triggered through `on tags`.|
6869
| `branch-push-force` | **NO** | `--force` flag when running `git push <branch-name>`. |
6970
| `tag` | **NO** | Push tag for the new/current commit. |
7071
| `tag-only-if-file-changes` | **NO** | Push tag for new commit only when file changes present. **DEFAULT:** true |
@@ -80,4 +81,4 @@ Note: The `GH_TOKEN` environment variable is **required** for GitHub API request
8081
[coverage_badge]: https://codecov.io/gh/ryancyq/github-signed-commit/graph/badge.svg?token=KZTD2F2MN2
8182
[coverage]: https://codecov.io/gh/ryancyq/github-signed-commit
8283
[maintainability_badge]: https://api.codeclimate.com/v1/badges/0de9dbec270ca85719c6/maintainability
83-
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability
84+
[maintainability]: https://codeclimate.com/github/ryancyq/github-signed-commit/maintainability

dist/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30387,6 +30387,9 @@ function resolveCurrentBranch(ref) {
3038730387
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
3038830388
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 : '';
3038930389
}
30390+
else if (ref.startsWith('refs/tags/')) {
30391+
return '';
30392+
}
3039030393
throw new Error(`Unsupported ref: ${ref}`);
3039130394
}
3039230395
function getContext() {

package-lock.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github/repo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ function resolveCurrentBranch(ref: string): string {
66
} else if (ref.startsWith('refs/pull/')) {
77
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
88
return github.context.payload.pull_request?.head?.ref ?? ''
9+
} else if (ref.startsWith('refs/tags/')) {
10+
return ''
911
}
1012

1113
throw new Error(`Unsupported ref: ${ref}`)

0 commit comments

Comments
 (0)