diff --git a/README.md b/README.md index ab51f2a6..501c0f8b 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ But if you wish to select or exclude specific linters, we give you full control | **ENV VAR** | **Default Value** | **Notes** | | ---------------------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | -| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s), relative to `DEFAULT_WORKSPACE`. | +| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s), relative to `DEFAULT_WORKSPACE`. Set to `.` to use the top-level of the `DEFAULT_WORKSPACE`. | | **CSS_FILE_NAME** | `.stylelintrc.json` | Filename for [Stylelint configuration](https://github.com/stylelint/stylelint) (ex: `.stylelintrc.yml`, `.stylelintrc.yaml`) | | **DEFAULT_BRANCH** | `master` | The name of the repository default branch. | | **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. | diff --git a/lib/functions/validation.sh b/lib/functions/validation.sh index 1f0e04b0..66c2e187 100755 --- a/lib/functions/validation.sh +++ b/lib/functions/validation.sh @@ -139,8 +139,15 @@ function GetValidationInfo() { # Remove first char ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}" fi - # Need to give it full path - TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/${ANSIBLE_DIRECTORY}" + + if [ -z "${ANSIBLE_DIRECTORY}" ] || [[ ${ANSIBLE_DIRECTORY} == "." ]]; then + # Catches the case where ANSIBLE_DIRECTORY="/" or ANSIBLE_DIRECTORY="." + TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}" + else + # Need to give it full path + TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/${ANSIBLE_DIRECTORY}" + fi + # Set the value ANSIBLE_DIRECTORY="${TEMP_ANSIBLE_DIRECTORY}" debug "Setting Ansible directory to: ${ANSIBLE_DIRECTORY}" diff --git a/lib/functions/worker.sh b/lib/functions/worker.sh index 0916220d..156954ac 100755 --- a/lib/functions/worker.sh +++ b/lib/functions/worker.sh @@ -195,7 +195,7 @@ function LintCodebase() { # Lint the file with the rules # ################################ LINT_CMD=$( - cd "${WORKSPACE_PATH}/ansible" || exit + cd "${ANSIBLE_DIRECTORY}" || exit ${LINTER_COMMAND} "${FILE}" 2>&1 ) ####################################