Skip to content

Commit 51aac47

Browse files
authored
fix: Make alias and rename safe (#31)
Signed-off-by: Steve Hipwell <[email protected]>
1 parent 63d20fb commit 51aac47

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
- Update _action-stars/generic-workflows_ from `0.7.0` to `0.7.1`. ([#29](https://github.com/action-stars/install-tool-from-github-release/pull/29)) _@dependabot_
2323
- Update _action-stars/generic-workflows_ from `0.7.1` to `0.7.2`. ([#30](https://github.com/action-stars/install-tool-from-github-release/pull/30)) _@dependabot_
2424

25+
### Fixed
26+
27+
- Fix `rename` & `alias` inputs to use the installation directory. ([#31](https://github.com/action-stars/install-tool-from-github-release/pull/31)) _@stevehipwell_
28+
2529
## [v0.2.5] - 2025-05-12
2630

2731
### Changed

action.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ runs:
121121
122122
- name: Install tool
123123
uses: pbrisbin/setup-tool-action@87ea9f382eb6b0357d78908ac3b61cc4d8f87ef3 # v2.2.2
124+
id: install
124125
with:
125126
github-token: ${{ inputs.github_token }}
126127
name: ${{ inputs.name || inputs.repository }}
@@ -142,30 +143,44 @@ runs:
142143
- name: Rename
143144
if: inputs.rename
144145
shell: bash
146+
env:
147+
INPUT_DIRECTORY: ${{ steps.install.outputs.directory }}
148+
INPUT_RENAME: ${{ inputs.rename }}
145149
run: |
146150
set -euo pipefail
147151
148-
input="${{ inputs.rename }}"
149-
before="${input%=*}"
150-
after="${input#*=}"
152+
before="${INPUT_RENAME%=*}"
153+
after="${INPUT_RENAME#*=}"
151154
152-
before_path="$(which "${before}")"
153-
after_path="$(dirname "${before_path}")/${after}"
155+
before_path="${INPUT_DIRECTORY}/${before}"
156+
after_path="${INPUT_DIRECTORY}/${after}"
157+
158+
if [[ ! -f "${before_path}" ]]; then
159+
echo "File does not exist: ${before_path}"
160+
exit 1
161+
fi
154162
155163
mv -f "${before_path}" "${after_path}"
156164
157165
- name: Alias
158166
if: inputs.alias
159167
shell: bash
168+
env:
169+
INPUT_DIRECTORY: ${{ steps.install.outputs.directory }}
170+
INPUT_ALIAS: ${{ inputs.alias }}
160171
run: |
161172
set -euo pipefail
162173
163-
input="${{ inputs.alias }}"
164-
target="${input%=*}"
165-
alias="${input#*=}"
174+
target="${INPUT_ALIAS%=*}"
175+
alias="${INPUT_ALIAS#*=}"
166176
167-
target_path="$(which "${target}")"
168-
alias_path="$(dirname "${target_path}")/${alias}"
177+
target_path="${INPUT_DIRECTORY}/${target}"
178+
alias_path="${INPUT_DIRECTORY}/${alias}"
179+
180+
if [[ ! -f "${target_path}" ]]; then
181+
echo "Target file does not exist: ${target_path}"
182+
exit 1
183+
fi
169184
170185
ln -s "${target_path}" "${alias_path}"
171186

0 commit comments

Comments
 (0)