mirror of
https://github.com/creyD/autopep8_action.git
synced 2026-04-12 19:40:28 +02:00
Added dry run parameter
This commit is contained in:
@@ -15,6 +15,8 @@ The following parameters can be used in your custom action configuration.
|
||||
| branch | :white_check_mark: | - | The specific branch you want to merge into. Use ${{ github.head_ref }} if you want to use this with pull requests. |
|
||||
| checkpath | :x: | '.' | The path autopep8 checks |
|
||||
| autoparameters | :x: | ' ' | Parameters to use with autopep8 |
|
||||
| dry | :x: | false | Dry-run the action to fail when detecting PEP-8 uncompliant files, instead of automatically fixing them. |
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ inputs:
|
||||
description: Parameters for autopep8
|
||||
required: false
|
||||
default: ''
|
||||
dry:
|
||||
description: Should this script apply autopep8 directly or just warn?
|
||||
required: false
|
||||
default: false
|
||||
|
||||
runs:
|
||||
using: 'docker'
|
||||
|
||||
@@ -32,16 +32,20 @@ autopep8 -i -r $INPUT_CHECKPATH $INPUT_AUTOPARAMETERS || echo "Problem running a
|
||||
|
||||
if ! git diff --quiet
|
||||
then
|
||||
echo "Commiting and pushing changes."
|
||||
# Calling method to configure the git environemnt
|
||||
git_setup
|
||||
# Switch to the actual branch
|
||||
git checkout $INPUT_BRANCH
|
||||
|
||||
git add "${INPUT_FILE_PATTERN}"
|
||||
|
||||
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
|
||||
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
|
||||
if $INPUT_DRY; then
|
||||
echo "Found non-compliant files!"
|
||||
exit 1
|
||||
else
|
||||
# Calling method to configure the git environemnt
|
||||
_git_setup
|
||||
echo "Commiting and pushing changes..."
|
||||
# Add changes to git
|
||||
git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}"
|
||||
# Commit and push changes back
|
||||
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
|
||||
git push origin
|
||||
echo "Changes pushed successfully."
|
||||
fi
|
||||
else
|
||||
echo "Nothing to commit. Exiting."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user