From 4dd2d7ede09f6a14ecca53d476d8252c01ab5287 Mon Sep 17 00:00:00 2001 From: Will Jessop Date: Mon, 23 Sep 2024 11:44:15 +0100 Subject: [PATCH] Allow specifying a working directory --- README.md | 2 ++ action.yml | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index a5ef377..3711168 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ permissions: - `ruby-version` - If your project has a `.ruby-version` file, this Action will use that version of Ruby. If not, this will be forwarded to the [ruby/setup-ruby](https://github.com/ruby/setup-ruby) action, so it takes the same values. - `autofix` - If set to `false`, the action will not attempt to auto-fix any errors. Defaults to `true`. +- `workdir` - If set the action will descend to this directory before running `bundle exec standardrb …`. Defaults to `.`. Example with options set: @@ -62,6 +63,7 @@ Example with options set: with: ruby-version: '3.3' autofix: false + workdir: my/app/subdirectory ``` ## Screenshots diff --git a/action.yml b/action.yml index e6781e8..444177c 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,9 @@ inputs: description: 'Whether autofixes should be committed back to the branch' required: false default: 'true' + WORKDIR: + description: "The directory from which to run the standardrb command. Default '.'" + default: '.' runs: using: composite @@ -19,6 +22,9 @@ runs: - name: Checkout code uses: actions/checkout@v4 + - name: Change to the workdir + run: pushd ${{ inputs.workdir }} + - name: Check for .ruby-version file id: use_ruby_version_or_default shell: bash @@ -66,6 +72,9 @@ runs: git push echo "::endgroup::" + - name: Change back to the root directory + run: popd + - name: Fail the build if Standard Ruby failed shell: bash if: ${{ steps.standardrb.outcome == 'failure' }}