Compare commits

..

41 Commits

Author SHA1 Message Date
503a6ec1b0 adc 2025-04-02 16:05:44 +08:00
636c6d14bf adc 2025-04-02 16:04:13 +08:00
0d8e43b3fa adc 2025-04-02 16:03:14 +08:00
0f7cd9f396 adc 2025-04-02 16:01:31 +08:00
526abd78a5 adc 2025-04-02 15:58:07 +08:00
c169f02ea5 sdf 2025-04-02 15:56:59 +08:00
db97f115ea sdf 2025-04-02 15:56:04 +08:00
7ed203bf31 sdf 2025-04-02 15:45:08 +08:00
b5b3ada390 sdf 2025-04-02 15:44:02 +08:00
6683284d90 size 2025-04-02 15:33:12 +08:00
8352cd3828 size 2025-04-02 15:31:57 +08:00
11fcf447e1 size 2025-04-02 15:30:46 +08:00
c483cd4683 size 2025-04-02 15:29:19 +08:00
f6930cc9cf size 2025-04-02 15:26:02 +08:00
845a78185e size 2025-04-02 15:24:20 +08:00
8f608d2438 size 2025-04-02 15:24:05 +08:00
71db570c75 size 2025-04-02 15:22:41 +08:00
1aa2b8982d size 2025-04-02 15:22:17 +08:00
a091284bc8 size 2025-04-02 14:05:16 +08:00
b433aab522 123 2025-03-31 12:00:45 +08:00
fac0feebe0 ss 2025-03-31 11:57:32 +08:00
ef36c56555 ss 2025-03-31 11:53:47 +08:00
5b6a81797c ss 2025-03-31 11:50:03 +08:00
f5a493d176 te 2025-03-31 11:40:23 +08:00
557add3507 te 2025-03-31 11:39:38 +08:00
865f668926 te 2025-03-31 11:38:08 +08:00
6427a54871 del
Some checks failed
Lint Code Base / Lint Code Base (push) Has been cancelled
tests / tests (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
git-auto-commit / git-auto-commit (push) Has been cancelled
2025-03-31 11:36:03 +08:00
2c1909d09e size limit
Some checks are pending
git-auto-commit / git-auto-commit (push) Waiting to run
Lint Code Base / Lint Code Base (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
tests / tests (push) Waiting to run
2025-03-31 11:13:35 +08:00
Stefan Zweifel
050015d406 Add Scope/Permissions documentation for PATs
Closes #347
2024-10-06 10:39:09 +02:00
scarf
573710f3d0 docs(README): fix broken protected branch docs link (#346) 2024-10-04 08:56:00 +02:00
Marcelo Trylesinski
e961da7576 Update README.md (#343) 2024-09-22 16:50:21 +02:00
dependabot[bot]
ac8823709a Bump github/super-linter from 6 to 7 (#342)
Bumps [github/super-linter](https://github.com/github/super-linter) from 6 to 7.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/super-linter/compare/v6...v7)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-02 08:16:51 +02:00
dependabot[bot]
be823a7e51 Bump github/super-linter from 5 to 6 (#335)
Bumps [github/super-linter](https://github.com/github/super-linter) from 5 to 6.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/super-linter/compare/v5...v6)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-08 08:26:25 +02:00
Stefan Zweifel
55a82ca24f Add Section on preventing infinite loops to README 2024-07-06 15:14:44 +02:00
Stefan Zweifel
18157e6f3b Update bug.yaml 2024-07-06 12:07:25 +02:00
Stefan Zweifel
7d779d0067 Update Bug Repo Form 2024-07-06 12:06:47 +02:00
Stefan Zweifel
efd424db0f Fix link to "new feature request" 2024-07-06 12:00:09 +02:00
Stefan Zweifel
5f3fa8aed3 Add docs about .github/workflows pushes
See #322
2024-07-06 11:43:22 +02:00
Stefan Zweifel
ee5525316d Update GPG Signing section in README 2024-07-02 20:41:34 +02:00
Stefan Zweifel
4b8a201e31 Add with ref github.head_ref to README 2024-04-13 10:35:11 +02:00
stefanzweifel
896cc0d225 Update CHANGELOG 2024-04-12 06:47:58 +00:00
7 changed files with 234 additions and 16 deletions

View File

@@ -5,7 +5,7 @@ body:
- type: markdown
attributes:
value: |
Before opening a bug report, please search for the behaviour in the existing issues.
Before opening a bug report, please search for the behaviour in existing issues or discussions.
---
@@ -17,7 +17,7 @@ body:
description: "Which exact version of git-auto-commit are you using in your Workflow?"
placeholder: "v4.14.0"
validations:
required: true
required: true
- type: dropdown
id: machine
attributes:
@@ -33,7 +33,7 @@ body:
id: bug-description
attributes:
label: Bug description
description: What exactly happened?
description: What exactly happened? Please describe your problem in detail.
validations:
required: true
- type: textarea
@@ -52,7 +52,7 @@ body:
id: example-workflow
attributes:
label: Example Workflow
description: Please share your GitHub Actions workflow which causes the bug. We use this to reproduce the error. No need for backticks here.
description: Please share the YAML-code of your GitHub Actions workflow which causes the bug. We use this to reproduce the error. If the workflow is in a private repostory, please provide a minimal example. (No need for backticks here, the pasted code will be correctly formatted.)
render: yaml
validations:
required: true
@@ -60,5 +60,10 @@ body:
id: logs
attributes:
label: Relevant log output
description: If applicable, provide relevant log output. No need for backticks here.
description: If applicable, provide relevant log output. Please copy and paste the output here, and make sure to remove any sensitive information. (No need for backticks here, the pasted code will be correctly formatted.)
render: shell
- type: input
id: repository-url
attributes:
label: Repository
description: If applicable, please provide the repository where the bug occurred.

View File

@@ -4,5 +4,5 @@ contact_links:
url: https://github.com/stefanzweifel/git-auto-commit-action/discussions/new?category=help
about: If you can't get something to work the way you expect, open a question in our discussion forums.
- name: Feature Request
url: https://github.com/tailwindlabs/tailwindcss/discussions/new?category=ideas
url: https://github.com/stefanzweifel/git-auto-commit-action/discussions/new?category=ideas
about: 'Suggest any ideas you have using our discussion forums.'

View File

@@ -12,7 +12,7 @@ jobs:
uses: actions/checkout@v4
- name: Lint Code Base
uses: github/super-linter@v5
uses: github/super-linter@v7
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_MARKDOWN: false

1
111.txt Normal file
View File

@@ -0,0 +1 @@
1sdlfjlasdf;ljf;ljas;ldfj23123

View File

@@ -1,14 +1,36 @@
# Changelog
# add sdfsf
# add sdf
# Changelog234234
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.0...HEAD)
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.1...HEAD)
> TBD
## [v5.0.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v5.0.0...v5.0.1) - 2024-04-12
### Fixed
- Fail if attempting to execute git commands in a directory that is not a git-repo. ([#326](https://github.com/stefanzweifel/git-auto-commit-action/pull/326)) [@ccomendant](https://github.com/@ccomendant)
### Dependency Updates
- Bump bats from 1.10.0 to 1.11.0 ([#325](https://github.com/stefanzweifel/git-auto-commit-action/pull/325)) [@dependabot](https://github.com/@dependabot)
- Bump release-drafter/release-drafter from 5 to 6 ([#319](https://github.com/stefanzweifel/git-auto-commit-action/pull/319)) [@dependabot](https://github.com/@dependabot)
### Misc
- Clarify `commit_author` input option ([#315](https://github.com/stefanzweifel/git-auto-commit-action/pull/315)) [@npanuhin](https://github.com/@npanuhin)
- Add step id explanation for output in README.md ([#324](https://github.com/stefanzweifel/git-auto-commit-action/pull/324)) [@ChristianVermeulen](https://github.com/@ChristianVermeulen)
- Linux is not UNIX ([#321](https://github.com/stefanzweifel/git-auto-commit-action/pull/321)) [@couling](https://github.com/@couling)
## [v5.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.16.0...v5.0.0) - 2023-10-06
New major release that bumps the default runtime to Node 20. There are no other breaking changes.

204
README.md
View File

@@ -1,4 +1,151 @@
# git-auto-commit Action
# abcd add haha ... git-auto-commit Action
# add env #!/usr/bin/env bash
set -o pipefail
readonly DEFAULT_FILE_MAXSIZE_MB="30"
readonly CONFIG_NAME="hooks.maxfilesize"
readonly NULLSHA="0000000000000000000000000000000000000000"
readonly EXIT_SUCCESS=0
readonly EXIT_FAILURE=1
readonly DEFAULT_REPO_MAXSIZE_MB="1024"
readonly CHECK_FLAG_ON=1
env
echo "CHECK_FLAG_ON=====$CHECK_FLAG_ON"
echo "PUSH_SIZE_CHECK_FLAG=====$PUSH_SIZE_CHECK_FLAG"
status="$EXIT_SUCCESS"
# skip this hook entirely if shell check is not open
check_flag=1 #${PUSH_SIZE_CHECK_FLAG}
if [[ $check_flag != $CHECK_FLAG_ON ]]; then
exit $EXIT_SUCCESS
fi
export REPO_MAX_SIZE=50
echo "REPO_MAX_FILE_SIZE===${REPO_MAX_FILE_SIZE}"
echo "REPO_MAX_SIZE===${REPO_MAX_SIZE}"
echo "REPO_CURRENT_SIZE===${REPO_CURRENT_SIZE}"
#######################################
# check the file max size limit
#######################################
# get maximum filesize (from repository-specific config)
maxsize_mb="${REPO_MAX_FILE_SIZE}"
if [[ "$?" != $EXIT_SUCCESS ]]; then
echo "failed to get ${CONFIG_NAME} from config"
exit "$EXIT_FAILURE"
fi
push_size="0"
# read lines from stdin (format: "<oldref> <newref> <refname>\n")
while read oldref newref refname; do
# skip branch deletions
if [[ "$newref" == "$NULLSHA" ]]; then
continue
fi
# find large objects
# check all objects from $oldref (possible $NULLSHA) to $newref, but
# skip all objects that have already been accepted (i.e. are referenced by
# another branch or tag).
new_branch_flag=0
if [[ "$oldref" == "$NULLSHA" ]]; then
target="$newref"
new_branch_flag=1
echo "You are creating a new remote branch,openI will check all files in commit history to find oversize files"
else
target="${oldref}..${newref}"
fi
echo "target==${target}"
maxsize=`expr $maxsize_mb \* 1048576`
# find objects in this push_size
# print like:
# 08da8e2ab9ae4095bf94dd71ac913132b880b463 commit 214
# 43e993b768ede5740e8c65de2ed6edec25053ea1 tree 185
# 4476971d76569039df7569af1b8d03c288f6b193 blob 20167318 b0417e6593a1.zip
files="$(git rev-list --objects "$target" | \
git cat-file $'--batch-check=%(objectname) %(objecttype) %(objectsize) %(rest)' | \
awk -F ' ' -v maxbytes="$maxsize" 'BEGIN {totalIn=0} {if( $3 > maxbytes && $2 == "blob") { totalIn+=$3; print $4} else { totalIn+=$3}} END { printf ("totalIn=\t%s",totalIn)}' )"
if [[ "$?" != $EXIT_SUCCESS ]]; then
echo "failed to check for large files in ref ${refname}"
continue
fi
IFS=$'\n'
# rewrite IFS to seperate line in $files
for file in $files; do
# if don't unset IFS,temp_array=(${file}) will get error answer
if [[ ${file} == totalIn=* ]]; then
IFS=$'\t'
temp_array=(${file})
push_size=${temp_array[1]}
continue
fi
unset IFS
if [[ "$status" == $EXIT_SUCCESS ]]; then
echo -e "Error: Your push was rejected because it contains files larger than $(numfmt --to=iec "$maxsize_mb") Mb"
echo "help document -- https://openi.pcl.ac.cn/zeizei/OpenI_Learning/src/branch/master/docs/git/repository_capacity_help.md"
echo "oversize files:"
# status="$EXIT_FAILURE"
fi
echo -e "\033[31m- ${file}\033[0m "
done
echo "push_size=======${push_size}"
if [[ "$status" != $EXIT_SUCCESS ]]; then
exit "$status"
fi
done
#######################################
# check the repo max size limit
#######################################
if [[ $push_size -eq "0" ]]; then
exit $EXIT_SUCCESS
fi
# if create new branch or tag,use count-objects -v to get pack size
if [[ $new_branch_flag -eq 1 ]]; then
size_kb=`git count-objects -v | grep 'size-pack' | sed 's/.*\(size-pack:\).//'`
size_pack_kb=`git count-objects -v | grep 'size:' | sed 's/.*\(size:\).//'`
total_kb=`expr $size_kb + $size_pack_kb`
let push_size=$total_kb*1024
fi
sizelimit_mb="${REPO_MAX_SIZE}"
let sizelimit_b=$sizelimit_mb*1024*1024
# repo size at here means the size of repo directory in server
reposize_b=${REPO_CURRENT_SIZE}
total=`expr $push_size + $reposize_b`
if [ $total -gt $sizelimit_b ]; then
echo "Error: Your push was rejected because the repository size is large than $sizelimit_mb Mb"
echo "see the help document--https://openi.pcl.ac.cn/zeizei/OpenI_Learning/src/branch/master/docs/git/repository_capacity_help.md"
exit $EXIT_FAILURE
fi
exit $EXIT_SUCCESS
v
> The GitHub Action for committing files for the 80% use case.
@@ -40,8 +187,11 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
# Other steps that change files in the repository
# Other steps that change files in the repository go here
# …
# Commit all changed files back to the repository
- uses: stefanzweifel/git-auto-commit-action@v5
@@ -231,10 +381,17 @@ storing the token as a secret in your repository and then passing the new token
token: ${{ secrets.PAT }}
```
If you create a personal access token, apply the `repo` and `workflow` scopes.
If you create a personal access token (classic), apply the `repo` and `workflow` scopes.
If you create a fine-grained personal access token, apply the `Contents`-permissions.
If you work in an organization and don't want to create a PAT from your personal account, we recommend using a [robot account](https://docs.github.com/en/github/getting-started-with-github/types-of-github-accounts) for the token.
### Prevent Infinite Loop when using a Personal Access Token
If you're using a Personal Access Token (PAT) to push commits to GitHub repository, the resulting commit or push can trigger other GitHub Actions workflows. This can result in an infinite loop.
If you would like to prevent this, you can add `skip-checks:true` to the commit message. See [Skipping workflow runs](https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs) for details.
### Change to file is not detected
Does your workflow change a file, but "git-auto-commit" does not detect the change? Check the `.gitignore` that applies to the respective file. You might have accidentally marked the file to be ignored by git.
@@ -271,11 +428,32 @@ The example below can be used as a starting point to generate a multiline commit
commit_message: ${{ steps.commit_message_step.outputs.commit_message }}
```
### Signing Commits & Other Git Command Line Options
### Signing Commits
Using command lines options needs to be done manually for each workflow which you require the option enabled. So for example signing commits requires you to import the gpg signature each and every time. The following list of actions are worth checking out if you need to automate these tasks regularly.
If you would like to sign your commits using a GPG key, you will need to use an additional action.
You can use the [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) action and follow its setup instructions.
- [Import GPG Signature](https://github.com/crazy-max/ghaction-import-gpg) (Suggested by [TGTGamer](https://github.com/tgtgamer))
As git-auto-commit by default does not use **your** username and email when creating a commit, you have to override these values in your workflow.
```yml
- name: "Import GPG key"
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: "Commit and push changes"
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_author: "${{ steps.import-gpg.outputs.name }} <${{ steps.import-gpg.outputs.email }}>"
commit_user_name: ${{ steps.import-gpg.outputs.name }}
commit_user_email: ${{ steps.import-gpg.outputs.email }}
```
See discussion [#334](https://github.com/stefanzweifel/git-auto-commit-action/discussions/334) for details.
### Use in forks from private repositories
@@ -403,13 +581,25 @@ please update your Workflow configuration and usage of [`actions/checkout`](http
Updating the `token` value with a Personal Access Token should fix your issues.
### git-auto-commit fails to push commit that creates or updates files in `.github/workflows/`
The default `GITHUB_TOKEN` issued by GitHub Action does not have permission to make changes to workflow files located in `.github/workflows/`.
To fix this, please create a personal access token (PAT) and pass the token to the `actions/checkout`-step in your workflow. (Similar to [how to push to protected branches](https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#push-to-protected-branches)).
If a PAT does not work for you, you could also create a new GitHub app and use it's token in your workflows. See [this comment in #87](https://github.com/stefanzweifel/git-auto-commit-action/issues/87#issuecomment-1939138661) for details.
See [#322](https://github.com/stefanzweifel/git-auto-commit-action/issues/322) for details and discussions around this topic.
### Push to protected branches
If your repository uses [protected branches](https://help.github.com/en/github/administering-a-repository/configuring-protected-branches) you have to make some changes to your Workflow for the Action to work properly: You need a Personal Access Token and you either have to allow force pushes or the Personal Access Token needs to belong to an Administrator.
If your repository uses [protected branches](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches) you have to make some changes to your Workflow for the Action to work properly: You need a Personal Access Token and you either have to allow force pushes or the Personal Access Token needs to belong to an Administrator.
First, you have to create a new [Personal Access Token (PAT)](https://github.com/settings/tokens/new),
store the token as a secret in your repository and pass the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step.
If you create a personal access token (classic), apply the `repo` and `workflow` scopes.
If you create a fine-grained personal access token, apply the `Contents`-permissions.
```yaml
- uses: actions/checkout@v4
with:

BIN
build.zip Normal file

Binary file not shown.