Skip to content

Commit 9ed8bc9

Browse files
kenjitagawaKenji Tagawa
andauthored
Add variable to change base path (#8)
* feat: ✨ add variable to change base path When using this with a self-hosted runner where we have found the need to be able to change the base path of the installation. * docs: 📝 add documentation on new input * refactor: remove need to have `/` at the end of base_path variable --------- Co-authored-by: Kenji Tagawa <kenji@tagawa.ca>
1 parent 8333a50 commit 9ed8bc9

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Then, set up this Action as a step in your Actions workflow, e.g. for a typical
2828
* `java_version`: The Java version to use. Default: `11`
2929
* `no_cache`: Do not use cached versions of the Spotbugs and FindSecBugs tools. Default: `false`
3030
* `path_prefix`: Add this path prefix to the start of file locations. Required: `false`
31+
* `base_path`: The base path to use for installing the tools. Default: `/home/runner/work/`
3132

3233
## Full sample workflow
3334

action.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ inputs:
4444
description: 'Add this path prefix to the start of file locations'
4545
required: false
4646

47+
# Allows for a custom runner home directory to be specified for self-hosted runners
48+
base_path:
49+
description: 'The home directory of the runner'
50+
required: false
51+
default: '/home/runner/work'
52+
53+
4754
runs:
4855
using: "composite"
4956
steps:
@@ -57,20 +64,20 @@ runs:
5764
id: cache-spotbugs
5865
uses: actions/cache@v3
5966
with:
60-
path: /home/runner/work/spotbugs+/spotbugs-${{ inputs.spotbugs_version }}
67+
path: ${{ inputs.base_path }}/spotbugs+/spotbugs-${{ inputs.spotbugs_version }}
6168
key: ${{ runner.os }}-spotbugs-${{ inputs.spotbugs_version }}
6269
- name: Cache FindSecBugs
6370
if: inputs.no_cache == 'false'
6471
id: cache-findsecbugs
6572
uses: actions/cache@v3
6673
with:
67-
path: /home/runner/work/findsecbugs+/findsecbugs-plugin-${{ inputs.findsecbugs_version }}.jar
74+
path: ${{ inputs.base_path }}/findsecbugs+/findsecbugs-plugin-${{ inputs.findsecbugs_version }}.jar
6875
key: ${{ runner.os }}-findsecbugs-${{ inputs.findsecbugs_version }}
6976
- name: Get SpotBugs
7077
if: inputs.no_cache == 'true' || steps.cache-spotbugs.outputs.cache-hit != 'true'
7178
env:
7279
INPUT_SPOTBUGS_VERSION: ${{ inputs.spotbugs_version }}
73-
SPOTBUGS_HOME: /home/runner/work/spotbugs+/
80+
SPOTBUGS_HOME: ${{ inputs.base_path }}/spotbugs+/
7481
run: |
7582
mkdir -p "${SPOTBUGS_HOME}"
7683
cd "${SPOTBUGS_HOME}"
@@ -84,7 +91,7 @@ runs:
8491
if: inputs.no_cache == 'true' || steps.cache-findsecbugs.outputs.cache-hit != 'true'
8592
env:
8693
INPUT_FINDSECBUGS_VERSION: ${{ inputs.findsecbugs_version }}
87-
FINDSECBUGS_HOME: /home/runner/work/findsecbugs+/
94+
FINDSECBUGS_HOME: ${{ inputs.base_path }}/findsecbugs+/
8895
run: |
8996
mkdir -p "${FINDSECBUGS_HOME}"
9097
cd "${FINDSECBUGS_HOME}"
@@ -97,9 +104,9 @@ runs:
97104
INPUT_FINDSECBUGS_VERSION: ${{ inputs.findsecbugs_version }}
98105
INPUT_SPOTBUGS_TARGET: ${{ inputs.spotbugs_target }}
99106
INPUT_SPOTBUGS_GLOB: ${{ inputs.spotbugs_filename_glob }}
100-
SPOTBUGS_HOME: /home/runner/work/spotbugs+/spotbugs-${{ inputs.spotbugs_version }}
101-
FINDSECBUGS_HOME: /home/runner/work/findsecbugs+/
102-
SPOTBUGS_WORKING: /home/runner/work/spotbugs_working+/
107+
SPOTBUGS_HOME: ${{ inputs.base_path }}/spotbugs+/spotbugs-${{ inputs.spotbugs_version }}
108+
FINDSECBUGS_HOME: ${{ inputs.base_path }}/findsecbugs+/
109+
SPOTBUGS_WORKING: ${{ inputs.base_path }}/spotbugs_working+/
103110
run: |
104111
mkdir -p "${SPOTBUGS_WORKING}"
105112
cd "${SPOTBUGS_WORKING}"
@@ -110,7 +117,7 @@ runs:
110117
if: inputs.path_prefix != null
111118
env:
112119
INPUT_PATH_PREFIX: ${{ inputs.path_prefix }}
113-
SPOTBUGS_WORKING: /home/runner/work/spotbugs_working+/
120+
SPOTBUGS_WORKING: ${{ inputs.base_path }}/spotbugs_working+/
114121
run: |
115122
cd "${SPOTBUGS_WORKING}"
116123
jq --arg prefix "${INPUT_PATH_PREFIX}" '.runs[].results[].locations[].physicalLocation.artifactLocation.uri |= $prefix + .' < spotbugs.sarif > spotbugs_edited.sarif
@@ -121,4 +128,4 @@ runs:
121128
if: inputs.upload_sarif == 'true'
122129
uses: github/codeql-action/upload-sarif@v2
123130
with:
124-
sarif_file: /home/runner/work/spotbugs_working+/spotbugs.sarif
131+
sarif_file: ${{ inputs.base_path }}/spotbugs_working+/spotbugs.sarif

0 commit comments

Comments
 (0)