Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 503a6ec1b0 | |||
| 636c6d14bf | |||
| 0d8e43b3fa | |||
| 0f7cd9f396 | |||
| 526abd78a5 | |||
| c169f02ea5 | |||
| db97f115ea | |||
| 7ed203bf31 | |||
| b5b3ada390 | |||
| 6683284d90 | |||
| 8352cd3828 | |||
| 11fcf447e1 | |||
| c483cd4683 | |||
| f6930cc9cf | |||
| 845a78185e | |||
| 8f608d2438 | |||
| 71db570c75 | |||
| 1aa2b8982d | |||
| a091284bc8 | |||
| b433aab522 | |||
| fac0feebe0 | |||
| ef36c56555 | |||
| 5b6a81797c | |||
| f5a493d176 | |||
| 557add3507 | |||
| 865f668926 | |||
| 6427a54871 | |||
| 2c1909d09e | |||
|
|
050015d406 | ||
|
|
573710f3d0 | ||
|
|
e961da7576 | ||
|
|
ac8823709a | ||
|
|
be823a7e51 | ||
|
|
55a82ca24f | ||
|
|
18157e6f3b | ||
|
|
7d779d0067 | ||
|
|
efd424db0f | ||
|
|
5f3fa8aed3 | ||
|
|
ee5525316d | ||
|
|
4b8a201e31 | ||
|
|
896cc0d225 |
15
.github/ISSUE_TEMPLATE/bug.yaml
vendored
15
.github/ISSUE_TEMPLATE/bug.yaml
vendored
@@ -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.
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/config.yml
vendored
2
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -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.'
|
||||
|
||||
2
.github/workflows/linter.yml
vendored
2
.github/workflows/linter.yml
vendored
@@ -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
|
||||
|
||||
26
CHANGELOG.md
26
CHANGELOG.md
@@ -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
204
README.md
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user