Skip to content

Commit

Permalink
Add working-directory input (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
dorny committed Aug 4, 2020
1 parent 14dd70c commit caef9be
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/pull-request-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 4 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit caef9be

Please sign in to comment.