Add working-directory input (#21)

This commit is contained in:
Michal Dorner 2020-07-02 22:56:14 +02:00
parent 14dd70c742
commit caef9bef1f
No known key found for this signature in database
GPG Key ID: 9EEE04B48DA36786
5 changed files with 29 additions and 0 deletions

View File

@ -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

View File

@ -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.

View File

@ -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).

4
dist/index.js vendored
View File

@ -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;

View File

@ -8,6 +8,11 @@ import * as git from './git'
async function run(): Promise<void> {
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