66
77``` yml
88on :
9- push :
10- branches : " main"
9+ pull_request :
1110jobs :
1211 job :
1312 permissions :
2524👨 Uses ` github.actor` as the default author \
2625🤖 Uses <b>@github-actions\[bot\]</b> as the default committer \
2726🔼 Pushes changes to the current branch or tag \
28- 🏷️ Will automatically use `--force` if it's a Git tag
27+ 🤩 Works great for the common use cases!
2928
3029A convenience wrapper with sensible defaults so that you don't have to do
3130` git add` , `git commit`, and `git push` manually all the time. 😉
@@ -41,6 +40,7 @@ A convenience wrapper with sensible defaults so that you don't have to do
4140on:
4241 push:
4342 branches: "main"
43+ pull_request:
4444jobs:
4545 job:
4646 permissions:
5555🔒 Make sure you have the `permissions` set to `contents : write`! We need to be
5656able to edit the repository contents to push things.
5757
58- <details><summary>You can also use this GitHub Action with tags/releases</summary>
59-
60- ` ` ` yml
61- on:
62- release:
63- types: released
64- jobs:
65- job:
66- permissions:
67- contents: write
68- runs-on: ubuntu-latest
69- steps:
70- - uses: actions/checkout@v4
71- - run: echo "$TAG" > VERSION.txt
72- env:
73- TAG: ${{ github.event.release.tag_name }}
74- - uses: actions4git/add-commit-push@v1
75- ` ` `
76-
77- </details>
78-
7958If you're looking to have more control than the options provided below, it's
8059best if you tap in to the `git` CLI directly. The only tricky bit is setting a
8160default Git user (it's unset by default). You can either set it manually or use
@@ -84,23 +63,14 @@ a premade action like [actions4git/setup-git] to configure the `user.name` and
8463
8564` ` ` yml
8665- uses: actions/checkout@v4
87-
8866- uses: actions4git/setup-git@v1
89- # OR
90- - run: |
91- git config user.name "$GITHUB_ACTOR"
92- git config user.email "[email protected] " 93- # OR
94- - run: |
95- git config user.name 'github-actions[bot]'
96- git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
97-
98- # Then you can do whatever you want!
99- - run: git add ...
100- - run: git rebase ...
101- - run: git merge ...
102- - run: git commit ...
103- - run: git push ...
67+ # Then you can do whatever you want as the @github-actions[bot] user!
68+ - run: git add random.txt
69+ - run: git tag --force v1.0.0
70+ - run: git rebase --interactive HEAD~3
71+ - run: git merge --squash feature-branch
72+ - run: git commit --message 'My custom commit message'
73+ - run: git push origin other-branch:main --force
10474` ` `
10575
10676# ## Inputs
@@ -130,8 +100,8 @@ a premade action like [actions4git/setup-git] to configure the `user.name` and
130100 the special value `github-actions` to use the <b>@github-actions\[bot\]</b>
131101 user as the author, or the special `me` value to use the current
132102 ` github.actor` user as the author. Note that this is different from the
133- ` commit-committer` . The author of a commit is who wrote the thing and the
134- committer is who committed it to Git. It's recommended to leave this as the
103+ ` commit-committer` . [ The author of a commit is who wrote the thing and the
104+ committer is who committed it to Git.] It's recommended to leave this as the
135105 default.
136106
137107- **`commit-author-name`:** The name of the author to associate with the commit.
@@ -165,14 +135,12 @@ a premade action like [actions4git/setup-git] to configure the `user.name` and
165135 entirely like `https://github.com/octocat/another-repo.git`. The default
166136 ` origin` is probably what you want.
167137
168- - **`push-refspec`:** A specific branch or tag name to push to. If this is a
169- tag, `push-force` will default to `true` unless explicitly set otherwise.
170- Defaults to whatever the current Git `HEAD` target is.
138+ - **`push-refspec`:** A specific branch or tag name to push to. If unset, this
139+ will just run `git push [repository]` with no refspec. Defaults to unset.
171140
172141- **`push-force`:** Whether or not to use the `--force` parameter when doing the
173142 ` git push` . You may need to specify this if you are rewriting history or
174- editing a tag. Defaults to `false` if the `push-refspec` is a branch and
175- ` true` if it's a tag.
143+ editing a tag. Defaults to `false`.
176144
177145# ## Outputs
178146
@@ -185,6 +153,7 @@ TODO!
185153TODO!
186154
187155<!-- prettier-ignore-start -->
156+ [actions4git/setup-git] : https://github.com/actions4git/setup-git
188157[Git Pathspecs and How to Use Them] : https://css-tricks.com/git-pathspecs-and-how-to-use-them/
189- [The author of a commit is who wrote the thing, and the committer is who committed it to Git.] : https://stackoverflow.com/questions/18750808/difference-between-author-and-committer-in-git
158+ [The author of a commit is who wrote the thing and the committer is who committed it to Git.] : https://stackoverflow.com/questions/18750808/difference-between-author-and-committer-in-git
190159<!-- prettier-ignore-end -->
0 commit comments