Fix: GITHUB_PATH should prepend (#690)
* GITHUB_PATH is prepend https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path * Check for replacing system binaries Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
This commit is contained in:
parent
38f6dfb49a
commit
29ea8cfc4e
2 changed files with 23 additions and 3 deletions
|
@ -399,7 +399,7 @@ func (cr *containerReference) extractPath(env *map[string]string) common.Executo
|
|||
s := bufio.NewScanner(reader)
|
||||
for s.Scan() {
|
||||
line := s.Text()
|
||||
localEnv["PATH"] = fmt.Sprintf("%s:%s", localEnv["PATH"], line)
|
||||
localEnv["PATH"] = fmt.Sprintf("%s:%s", line, localEnv["PATH"])
|
||||
}
|
||||
|
||||
env = &localEnv
|
||||
|
|
24
pkg/runner/testdata/env-and-path/push.yaml
vendored
24
pkg/runner/testdata/env-and-path/push.yaml
vendored
|
@ -13,10 +13,30 @@ jobs:
|
|||
echo "$HOME/someOtherFolder" >> $GITHUB_PATH
|
||||
- name: "Check PATH"
|
||||
run: |
|
||||
if [[ ! "${PATH}" =~ .*"$HOME/"someFolder.*"$HOME/"someOtherFolder ]]; then
|
||||
echo "${PATH} doesn't match .*someFolder.*someOtherFolder"
|
||||
echo "${PATH}"
|
||||
if [[ ! "${PATH}" =~ .*"$HOME/"someOtherFolder.*"$HOME/"someFolder.* ]]; then
|
||||
echo "${PATH} doesn't match .*someOtherFolder.*someFolder.*"
|
||||
exit 1
|
||||
fi
|
||||
- name: "Prepend"
|
||||
run: |
|
||||
if ls | grep -q 'called ls' ; then
|
||||
echo 'ls was overridden already?'
|
||||
exit 2
|
||||
fi
|
||||
path_add=$(mktemp -d)
|
||||
cat > $path_add/ls <<LS
|
||||
#!/bin/sh
|
||||
echo 'called ls'
|
||||
LS
|
||||
chmod +x $path_add/ls
|
||||
echo $path_add >> $GITHUB_PATH
|
||||
- name: "Verify prepend"
|
||||
run: |
|
||||
if ! ls | grep -q 'called ls' ; then
|
||||
echo 'ls was not overridden'
|
||||
exit 2
|
||||
fi
|
||||
- name: "Write single line env to $GITHUB_ENV"
|
||||
run: |
|
||||
echo "KEY=value" >> $GITHUB_ENV
|
||||
|
|
Loading…
Reference in a new issue