diff --git a/README.md b/README.md index 9519c4a..580dd15 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,6 @@ Determines whether the action should fail if the code needs to be reformatted. - Default: `no` - Accepted values: `yes`, `no` -## `auto_commit` - -Determines whether the action should automatically commit the changes made by the `ReSharper's CleanupCode Command-Line Tool`. - -- Required: `false` -- Default: `yes` -- Accepted values: `yes`, `no` - ## `jb_cleanup_code_arg` Additional arguments to pass to the `ReSharper's CleanupCode Command-Line Tool`. Configure the tool with command-line parameters, @@ -57,27 +49,6 @@ e.g.: `--verbosity=INFO --profile=Built-in: Full Cleanup --exclude=**UnitTests/* - Required: `false` - Default: `--verbosity=WARN` -## `commit_message` - -The commit message to use if `auto_commit` is set to `yes`. - -- Required: `false` -- Default: `Cleanup code` - -## `commit_creator_email` - -The email address to use for the git user who creates the commit if `auto_commit` is set to `yes`. - -- Required: `false` -- Default: `cleanupcode@github.action` - -## `commit_creator_name` - -The name to use for the git user who creates the commit if `auto_commit` is set to `yes`. - -- Required: `false` -- Default: `CleanupCode GitHub Action` - # [ReSharper CLI CleanupCode GitHub Action Demo Usage](https://github.com/ArturWincenciak/ReSharper_CleanupCode_Demo) In that demo project, you will find all the knowledge you need to effectively start using this action. @@ -99,26 +70,6 @@ steps: solution: 'ReSharperCleanupCodeDemo.sln' ``` -That configuration means that the action does clean up and all cleaned up code will be committed and pushed into remote repo. -Commit will be performed with default commit message, git user email and name. - -- default commit message: `Clean up code by ReSharper CLI CleanupCode Tool` -- default git user email: `cleanupcode@github.action` -- default git user name: `CleanupCode Action` - -## Change commit message, git user email and name - -```yaml -steps: - - name: Cleanup Code - uses: ArturWincenciak/ReSharper_CleanupCode@v2.0 - with: - solution: 'ReSharperCleanupCodeDemo.sln' - commit_message: 'Clean up the code' - commit_creator_email: 'knuth.conway@surreal.number' - commit_creator_name: 'Knuth Conway' -``` - ## Interrupt your CI/CD pipeline if Cleanup detected the code needs to be cleaned up ```yaml @@ -133,7 +84,7 @@ steps: If this setting is enabled, the process will stop and return an error code if it finds that the code needs to be cleaned up. This can be helpful for stopping the pipeline from continuing if there are problems with the code. -## No interrupt and no clean up +## No interrupt your CI/CD pipeline if Cleanup detected the code needs to be cleaned up ```yaml steps: @@ -142,18 +93,10 @@ steps: with: solution: 'ReSharperCleanupCodeDemo.sln' fail_on_reformat_needed: 'no' - auto_commit: 'no' ``` -At times, you may want to disable automatic clean up code and continue with the execution of your CI/CD pipeline, for -instance, when you need to debug subsequent steps without performing clean up. - -## Interrupt the pipeline vs Clean up code -Note that if you set the action to automatically clean up code (which can be very helpful), you risk encountering the -need to resolve conflicts later if you forget to pull the automatically-committed changes. -For some, interrupting the CI/CD pipeline and performing code cleanup locally in your IDE or by console command -may be a more convenient option. +At times, you may want to disable the interruption and continue with the execution of your CI/CD pipeline, for instance, when you need to debug subsequent steps without performing clean up. ### Perform clean up your code locally with a fully automated commit and save your time @@ -198,11 +141,7 @@ jobs: with: solution: 'ReSharperCleanupCodeDemo.sln' fail_on_reformat_needed: 'no' - auto_commit: 'yes' jb_cleanup_code_arg: '--verbosity=INFO --profile=Built-in: Full Cleanup --exclude=**UnitTests/**.*' - commit_message: 'Cleanup code by ReSharper CLI CleanupCode GitHub Action' - commit_creator_email: 'cleanup@up.action' - commit_creator_name: 'Clean Up' ``` ### Sequence of actions performed by the prepared GitHub Action - `Checkout`: download the source code from the current repository where the Action was @@ -252,15 +191,11 @@ jobs: - name: Cleanup Code id: cleanup - uses: ArturWincenciak/ReSharper_CleanupCode@v2.0 + uses: ArturWincenciak/ReSharper_CleanupCode@v3.0 with: solution: 'ReSharperCleanupCodeDemo.sln' fail_on_reformat_needed: 'no' - auto_commit: 'yes' jb_cleanup_code_arg: '--verbosity=INFO --profile=Almost Full Cleanup --exclude=**UnitTests/**.*' - commit_message: 'Cleanup code by ReSharper CLI CleanupCode GitHub Action' - commit_creator_email: 'cleanupcode@github.action' - commit_creator_name: 'CleanupCode Action' inspection: runs-on: ubuntu-latest diff --git a/action.yml b/action.yml index 3a83493..5ff9967 100644 --- a/action.yml +++ b/action.yml @@ -14,30 +14,14 @@ inputs: description: 'Determines whether the action should fail if the code needs to be reformatted' required: false default: 'no' - auto_commit: - description: 'Determines whether the action should automatically commit the changes made by the ReSharpers CleanupCode Command-Line Tool' - required: false - default: 'yes' jb_cleanup_code_arg: description: 'Additional arguments to pass to the ReSharpers CleanupCode Command-Line Tool. Configure the tool with command-line parameters e.g. --verbosity=INFO --profile=Built-in: Full Cleanup --exclude=**UnitTests/**.*' required: false default: '--verbosity=WARN' - commit_message: - description: 'The commit message to use if auto_commit is set to yes' - required: false - default: "Clean up code by ReSharper CLI CleanupCode Tool" - commit_creator_email: - description: 'The email address to use for the git user who creates the commit if auto_commit is set to yes' - required: false - default: "cleanupcode@github.action" - commit_creator_name: - description: 'The name to use for the git user who creates the commit if auto_commit is set to yes' - required: false - default: "CleanupCode Action" runs: using: composite steps: - name: Run Script - run: ${GITHUB_ACTION_PATH}/entrypoint.sh "${{ inputs.solution }}" "${{ inputs.fail_on_reformat_needed }}" "${{ inputs.auto_commit }}" "${{ inputs.jb_cleanup_code_arg }}" "${{ inputs.commit_message }}" "${{ inputs.commit_creator_email }}" "${{ inputs.commit_creator_name }}" + run: ${GITHUB_ACTION_PATH}/entrypoint.sh "${{ inputs.solution }}" "${{ inputs.fail_on_reformat_needed }}" "${{ inputs.jb_cleanup_code_arg }}" shell: bash \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 67f2ac2..72b134d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,11 +7,7 @@ EXIT_WITH_FAST_FAIL=2 INPUT_SOLUTION=$1 INPUT_FAIL_ON_REFORMAT_NEEDED=$2 -INPUT_AUTO_COMMIT=$3 -INPUT_JB_CLEANUP_CODE_ARG=$4 -INPUT_COMMIT_MESSAGE=$5 -INPUT_COMMIT_CREATOR_EMAIL=$6 -INPUT_COMMIT_CREATOR_NAME=$7 +INPUT_JB_CLEANUP_CODE_ARG=$3 echo "" echo "--- --- ---" @@ -19,16 +15,7 @@ echo "Alright GitHub Action Cleanup Code Command-Line Tool" echo "Your setup:" echo "- Solution: [${INPUT_SOLUTION}]" echo "- Fail on re-format needed: [${INPUT_FAIL_ON_REFORMAT_NEEDED}]" -echo "- Auto commit re-formatted code: [${INPUT_AUTO_COMMIT}]" echo "- ReSharper CLI CleanupCode arguments: [${INPUT_JB_CLEANUP_CODE_ARG}]" -echo "- Commit message: [${INPUT_COMMIT_MESSAGE}]" -echo "- Commit creator (git user) e-mail: [${INPUT_COMMIT_CREATOR_EMAIL}]" -echo "- Commit creator (git user) name: [${INPUT_COMMIT_CREATOR_NAME}]" -if [ "${INPUT_FAIL_ON_REFORMAT_NEEDED}" = "yes" ] && [ "${INPUT_AUTO_COMMIT}" = "yes" ]; then - echo "NOTICE: you have set that the execution will fast fail on re-format needed" - echo "NOTICE: auto commit will not be executed because the execution will terminate with fail when re-format is needed" - echo "NOTICE: if you want to auto commit execute call the script with '-f no -a yes' arguments" -fi echo "--- --- ---" echo "" @@ -49,16 +36,6 @@ if [ "${INPUT_FAIL_ON_REFORMAT_NEEDED}" != "yes" ] && [ "${INPUT_FAIL_ON_REFORMA exit ${INVALID_ARGUMENT_ERROR} fi -if [ "${INPUT_AUTO_COMMIT}" != "yes" ] && [ "${INPUT_AUTO_COMMIT}" != "no" ]; then - echo "" - echo "--- --- ---" - echo "INVALID ARGUMENT OF '-a' equals '${INPUT_AUTO_COMMIT}'" - echo "Set 'yes' or 'no' or omit to use default equals 'no'" - echo "--- --- ---" - echo "" - exit ${INVALID_ARGUMENT_ERROR} -fi - # # Parse arguments and put them into an array to call command # I'm at a loss for words to describe how I managed to nail this function @@ -119,84 +96,4 @@ if [ "${INPUT_FAIL_ON_REFORMAT_NEEDED}" = "yes" ]; then exit ${EXIT_WITH_FAST_FAIL} fi -if [ "${INPUT_AUTO_COMMIT}" = "no" ]; then - echo "" - echo "--- --- ---" - echo "There is re-formatted code but it will not be auto committed" - echo "--- --- ---" - echo "" - exit ${SUCCESS} -fi - -echo "" -echo "--- --- ---" -echo "There is re-formatted code to be committed" -echo "--- --- ---" -echo "" - -git diff --name-only - -echo "" -echo "--- --- ---" -echo "Git Diff" -echo "--- --- ---" -echo "" - -git diff - -echo "" -echo "--- --- ---" -echo "Add all changes to stage" -echo "--- --- ---" -echo "" - -git add . - -echo "" -echo "--- --- ---" -echo "Staged files to be committed" -echo "--- --- ---" -echo "" - -git diff --staged --name-only - -echo "" -echo "--- --- ---" -echo "Creating commit" -echo "--- --- ---" -echo "" - -git config --global user.email "${INPUT_COMMIT_CREATOR_EMAIL}" -git config --global user.name "${INPUT_COMMIT_CREATOR_NAME}" -git commit -m "${INPUT_COMMIT_MESSAGE}" - -echo "" -echo "--- --- ---" -echo "Commit has been created" -echo "--- --- ---" -echo "" - -git status - -echo "" -echo "--- --- ---" -echo "Push the commit" -echo "--- --- ---" -echo "" - -git push - -echo "" -echo "--- --- ---" -echo "Commit has been pushed" -echo "--- --- ---" -echo "" - -git status - -echo "" -echo "--- --- ---" -echo "All re-formatted code has been committed and pushed with success" -echo "--- --- ---" -echo "" -exit ${SUCCESS} +exit ${SUCCESS} \ No newline at end of file