mirror of
https://github.com/creyD/autopep8_action.git
synced 2026-04-17 22:00:31 +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. |
|
| 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 |
|
| checkpath | :x: | '.' | The path autopep8 checks |
|
||||||
| autoparameters | :x: | ' ' | Parameters to use with autopep8 |
|
| 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
|
### Example
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ inputs:
|
|||||||
description: Parameters for autopep8
|
description: Parameters for autopep8
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
dry:
|
||||||
|
description: Should this script apply autopep8 directly or just warn?
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
|
|||||||
@@ -32,16 +32,20 @@ autopep8 -i -r $INPUT_CHECKPATH $INPUT_AUTOPARAMETERS || echo "Problem running a
|
|||||||
|
|
||||||
if ! git diff --quiet
|
if ! git diff --quiet
|
||||||
then
|
then
|
||||||
echo "Commiting and pushing changes."
|
if $INPUT_DRY; then
|
||||||
# Calling method to configure the git environemnt
|
echo "Found non-compliant files!"
|
||||||
git_setup
|
exit 1
|
||||||
# Switch to the actual branch
|
else
|
||||||
git checkout $INPUT_BRANCH
|
# Calling method to configure the git environemnt
|
||||||
|
_git_setup
|
||||||
git add "${INPUT_FILE_PATTERN}"
|
echo "Commiting and pushing changes..."
|
||||||
|
# Add changes to git
|
||||||
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
|
git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}"
|
||||||
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
|
# 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
|
else
|
||||||
echo "Nothing to commit. Exiting."
|
echo "Nothing to commit. Exiting."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user