diff --git a/.github/workflows/pull-request-verification.yml b/.github/workflows/pull-request-verification.yml index 0ce1af80..6a29ee66 100644 --- a/.github/workflows/pull-request-verification.yml +++ b/.github/workflows/pull-request-verification.yml @@ -54,3 +54,19 @@ jobs: - name: filter-test if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true' run: exit 1 + + test-wd-without-token: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + path: somewhere + - uses: ./somewhere + id: filter + with: + token: '' + working-directory: somewhere + filters: '.github/filters.yml' + - name: filter-test + if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true' + run: exit 1 diff --git a/README.md b/README.md index 8ea0ca5c..580026c1 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Output variables can be later used in the `if` clause to conditionally run speci ### Inputs - **`token`**: GitHub Access Token - defaults to `${{ github.token }}` so you don't have to explicitly provide it. +- **`working-directory`: Relative path under $GITHUB_WORKSPACE where the repository was checked out. Useful only if you checked out your repository under custom path. - **`base`**: Git reference (e.g. branch name) against which the changes will be detected. Defaults to repository default branch (e.g. master). If it references same branch it was pushed to, changes are detected against the most recent commit before the push. This option is ignored if action is triggered by *pull_request* event. diff --git a/action.yml b/action.yml index 723e07eb..990c420d 100644 --- a/action.yml +++ b/action.yml @@ -6,6 +6,9 @@ inputs: description: 'GitHub Access Token' required: false default: ${{ github.token }} + working-directory: + description: 'Relative path under $GITHUB_WORKSPACE where the repository was checked out.' + required: false base: description: | Git reference (e.g. branch name) against which the changes will be detected. Defaults to repository default branch (e.g. master). diff --git a/dist/index.js b/dist/index.js index 9f57a0b6..da21598c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4500,6 +4500,10 @@ const git = __importStar(__webpack_require__(136)); function run() { return __awaiter(this, void 0, void 0, function* () { try { + const workingDirectory = core.getInput('working-directory', { required: false }); + if (workingDirectory) { + process.chdir(workingDirectory); + } const token = core.getInput('token', { required: false }); const filtersInput = core.getInput('filters', { required: true }); const filtersYaml = isPathInput(filtersInput) ? getConfigFileContent(filtersInput) : filtersInput; diff --git a/src/main.ts b/src/main.ts index 78c480c6..9ffed55a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,6 +8,11 @@ import * as git from './git' async function run(): Promise { try { + const workingDirectory = core.getInput('working-directory', {required: false}) + if (workingDirectory) { + process.chdir(workingDirectory) + } + const token = core.getInput('token', {required: false}) const filtersInput = core.getInput('filters', {required: true}) const filtersYaml = isPathInput(filtersInput) ? getConfigFileContent(filtersInput) : filtersInput