Skip to content

Commit f30d455

Browse files
authored
give up lol
1 parent 4bf000b commit f30d455

File tree

5 files changed

+51
-137
lines changed

5 files changed

+51
-137
lines changed

.github/workflows/test-action.yml

Lines changed: 0 additions & 95 deletions
This file was deleted.

README.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
```yml
88
on:
9-
pull_request:
9+
push:
10+
branches: "main"
1011
jobs:
1112
job:
1213
permissions:
@@ -35,7 +36,8 @@ A convenience wrapper with sensible defaults so that you don't have to do
3536

3637
```yml
3738
on:
38-
pull_request:
39+
push:
40+
branches: "main"
3941
jobs:
4042
job:
4143
permissions:
@@ -119,12 +121,15 @@ a premade action like [actions4git/setup-git] to configure the `user.name` and
119121
`false`.
120122

121123
- **`commit-author`:** A `Name Here <[email protected]>` AiO author name &
122-
email string. This is a shortcut alternative to the independent
123-
`commit-author-name` and `commit-author-email` options that are also
124-
available. This defaults to the current `github.actor`. Note that this is
125-
different from the `commit-committer`. [The author of a commit is who wrote
126-
the thing, and the committer is who committed it to Git.] It's recommended to
127-
leave this as the default.
124+
email string. This is a shortcut alternative to the independant
125+
'commit-author-name' and `commit-author-email` options that are also
126+
available. This defaults to <b>@github-actions\[bot\]</b>. You can set this to
127+
the special value `github-actions` to use the <b>@github-actions\[bot\]</b>
128+
user as the author, or the special `me` value to use the current
129+
`github.actor` user as the author. Note that this is different from the
130+
`commit-committer`. The author of a commit is who wrote the thing and the
131+
committer is who committed it to Git. It's recommended to leave this as the
132+
default.
128133

129134
- **`commit-author-name`:** The name of the author to associate with the commit.
130135
Should be left unspecified if `commit-author` is specified.
@@ -134,10 +139,11 @@ a premade action like [actions4git/setup-git] to configure the `user.name` and
134139

135140
- **`commit-committer`:** A `Name Here <[email protected]>` AiO author name
136141
& email string. This input is a shortcut for the `commit-committer-name` and
137-
`commit-committer-email` inputs that can also be individually specified. This
138-
defaults to the `github-actions[bot]` user which is probably what you want.
139-
It's recommended to change the `commit-author` before changing the
140-
`commit-committer`.
142+
`commit-committer-email` inputs that can also be individually specified. You
143+
can set this to the special value `github-actions` to use the
144+
<b>@github-actions\[bot\]</b> user as the committer, or the special `me` value
145+
to use the current `github.actor` user as the committer. If this input is
146+
unspecified, the committer defaults to the author.
141147

142148
- **`commit-committer-name`:** The name of the committer to associate with the
143149
commit. Should be left unspecified if `commit-committer` is specified.
@@ -173,11 +179,7 @@ TODO!
173179

174180
![Bun](https://img.shields.io/static/v1?style=for-the-badge&message=Bun&color=000000&logo=Bun&logoColor=FFFFFF&label=)
175181

176-
**How do I test my changes?**
177-
178-
The easiest way is to open a Draft Pull Request either against the upstream
179-
repository or against your own fork's main branch and watch the GitHub Actions
180-
do their thing.
182+
TODO!
181183

182184
<!-- prettier-ignore-start -->
183185
[Git Pathspecs and How to Use Them]: https://css-tricks.com/git-pathspecs-and-how-to-use-them/

action.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ inputs:
3434
A 'Name Here <[email protected]>' AiO author name & email string. This
3535
is a shortcut alternative to the independant 'commit-author-name' and
3636
'commit-author-email' options that are also available. This defaults to
37-
the current 'github.actor'. Note that this is different from the
38-
'commit-committer'. The author of a commit is who wrote the thing and the
39-
committer is who committed it to Git. It's recommended to leave this as
40-
the default.
41-
default: |
42-
${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
37+
@github-actions[bot]. You can set this to the special value
38+
'github-actions' to use the @github-actions[bot] user as the author, or
39+
the special 'me' value to use the current 'github.actor' user as the
40+
author. Note that this is different from the 'commit-committer'. The
41+
author of a commit is who wrote the thing and the committer is who
42+
committed it to Git. It's recommended to leave this as the default.
43+
default: github-actions[bot]
4344
commit-author-name:
4445
description: >
4546
The name of the author to associate with the commit. Should be left
@@ -53,11 +54,10 @@ inputs:
5354
A 'Name Here <[email protected]>' AiO author name & email string. This
5455
input is a shortcut for the 'commit-committer-name' and
5556
'commit-committer-email' inputs that can also be individually specified.
56-
This defaults to the 'github-actions[bot]' user which is probably what you
57-
want. It's recommended to change the 'commit-author' before changing the
58-
'commit-commiter'.
59-
default: |
60-
github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
57+
You can set this to the special value 'github-actions' to use the
58+
@github-actions[bot] user as the committer, or the special 'me' value to
59+
use the current 'github.actor' user as the committer. If this input is
60+
unspecified, the committer defaults to the author.
6161
commit-committer-name:
6262
description: >
6363
The name of the committer to associate with the commit. Should be left

src/main.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,26 @@ let GIT_COMMITTER_EMAIL: string;
3131
if (core.getInput("commit-committer")) {
3232
assert.equal(core.getInput("commit-committer-name"), "");
3333
assert.equal(core.getInput("commit-committer-email"), "");
34-
[GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL] = core
35-
.getInput("commit-committer")
36-
.match(/^\s+(.+)\s+<(.+)>\s+$/)
37-
.slice(1);
34+
if (
35+
/^\s+@?github[-_]?actions(?:\[bot\])?\s+$/.test(
36+
core.getInput("commit-committer")
37+
)
38+
) {
39+
GIT_COMMITTER_NAME = "github-actions[bot]";
40+
GIT_COMMITTER_EMAIL =
41+
"41898282+github-actions[bot]@users.noreply.github.com";
42+
} else if (/^\s+@?me\s+$/.test(core.getInput("commit-committer"))) {
43+
GIT_COMMITTER_NAME = process.env.GITHUB_ACTOR;
44+
GIT_COMMITTER_EMAIL = `${process.env.GITHUB_ACTOR_ID}+${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
45+
} else {
46+
[GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL] = core
47+
.getInput("commit-committer")
48+
.match(/^\s+(.+)\s+<(.+)>\s+$/)
49+
.slice(1);
50+
}
3851
} else {
39-
GIT_COMMITTER_NAME = core.getInput("commit-committer-name", {
40-
required: true,
41-
});
42-
GIT_COMMITTER_EMAIL = core.getInput("commit-committer-email", {
43-
required: true,
44-
});
52+
GIT_COMMITTER_NAME = core.getInput("commit-committer-name");
53+
GIT_COMMITTER_EMAIL = core.getInput("commit-committer-email");
4554
}
4655

4756
const commitMessage = core.getInput("commit-message");
@@ -105,8 +114,8 @@ if (exitCode) {
105114
env: {
106115
GIT_AUTHOR_NAME,
107116
GIT_AUTHOR_EMAIL,
108-
GIT_COMMITTER_NAME,
109-
GIT_COMMITTER_EMAIL,
117+
...(GIT_COMMITTER_NAME && { GIT_COMMITTER_NAME }),
118+
...(GIT_COMMITTER_EMAIL && { GIT_COMMITTER_EMAIL }),
110119
},
111120
})`git commit --message ${commitMessage}`;
112121
const { stdout } = await $({

test/README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)