Skip to content

Commit

Permalink
Add WORKING_DIRECTORY environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
m-herold committed Nov 11, 2020
1 parent f3d1a1d commit 01a1495
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ jobs:
run: diff <(docker run -v $(pwd):$(pwd) -w $(pwd) --rm action-swiftlint|sort) expected.txt
working-directory: ./test/Warnings
shell: bash

- name: Output on Warnings with WORKING_DIRECTORY environment variable
run: diff <(docker run -v $(pwd):$(pwd) -w $(pwd) --rm --env WORKING_DIRECTORY=Warnings action-swiftlint|sort) Warnings/expected.txt
working-directory: ./test
shell: bash
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM norionomura/swiftlint:swift-5.1
LABEL version="3.1.0"
LABEL repository="https://github.com/norio-nomura/action-swiftlint"
LABEL homepage="https://github.com/norio-nomura/action-swiftlint"
LABEL repository="https://github.com/m-herold/action-swiftlint"
LABEL homepage="https://github.com/m-herold/action-swiftlint"
LABEL maintainer="Norio Nomura <norio.nomura@gmail.com>"

LABEL "com.github.actions.name"="GitHub Action for SwiftLint"
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
uses: norio-nomura/action-swiftlint@3.1.0
env:
DIFF_BASE: ${{ github.base_ref }}
- name: GitHub Action for SwiftLint (Different working directory)
uses: norio-nomura/action-swiftlint@3.1.0
env:
WORKING_DIRECTORY: Source
```
## Secrets
Expand Down
7 changes: 6 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ function convertToGitHubActionsLoggingCommands() {
sed -E 's/^(.*):([0-9]+):([0-9]+): (warning|error|[^:]+): (.*)/::\4 file=\1,line=\2,col=\3::\5/'
}

if ! ${WORKING_DIRECTORY+false};
then
cd ${WORKING_DIRECTORY}
fi

if ! ${DIFF_BASE+false};
then
changedFiles=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $DIFF_BASE) -- '*.swift')
changedFiles=$(git --no-pager diff --name-only --relative FETCH_HEAD $(git merge-base FETCH_HEAD $DIFF_BASE) -- '*.swift')

if [ -z "$changedFiles" ]
then
Expand Down

0 comments on commit 01a1495

Please sign in to comment.