2021-05-06 08:30:12 -05:00
|
|
|
name: env-and-path
|
|
|
|
on: push
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: "Append to $GITHUB_PATH"
|
|
|
|
run: |
|
|
|
|
echo "$HOME/someFolder" >> $GITHUB_PATH
|
|
|
|
- name: "Append some more to $GITHUB_PATH"
|
|
|
|
run: |
|
|
|
|
echo "$HOME/someOtherFolder" >> $GITHUB_PATH
|
|
|
|
- name: "Check PATH"
|
|
|
|
run: |
|
2021-05-18 08:22:39 -05:00
|
|
|
echo "${PATH}"
|
|
|
|
if [[ ! "${PATH}" =~ .*"$HOME/"someOtherFolder.*"$HOME/"someFolder.* ]]; then
|
|
|
|
echo "${PATH} doesn't match .*someOtherFolder.*someFolder.*"
|
2021-05-06 08:30:12 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-05-18 08:22:39 -05:00
|
|
|
- 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
|
2021-05-06 08:30:12 -05:00
|
|
|
- name: "Write single line env to $GITHUB_ENV"
|
|
|
|
run: |
|
|
|
|
echo "KEY=value" >> $GITHUB_ENV
|
|
|
|
- name: "Check single line env"
|
|
|
|
run: |
|
|
|
|
if [[ "${KEY}" != "value" ]]; then
|
2021-11-19 11:36:50 -06:00
|
|
|
echo "${KEY} doesn't == 'value'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
- name: "Write single line env with more than one 'equals' signs to $GITHUB_ENV"
|
|
|
|
run: |
|
|
|
|
echo "KEY=value=anothervalue" >> $GITHUB_ENV
|
|
|
|
- name: "Check single line env"
|
|
|
|
run: |
|
|
|
|
if [[ "${KEY}" != "value=anothervalue" ]]; then
|
|
|
|
echo "${KEY} doesn't == 'value=anothervalue'"
|
2021-05-06 08:30:12 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
- name: "Write multiline env to $GITHUB_ENV"
|
|
|
|
run: |
|
|
|
|
echo 'KEY2<<EOF' >> $GITHUB_ENV
|
|
|
|
echo value2 >> $GITHUB_ENV
|
|
|
|
echo 'EOF' >> $GITHUB_ENV
|
|
|
|
- name: "Check multiline line env"
|
|
|
|
run: |
|
|
|
|
if [[ "${KEY2}" != "value2" ]]; then
|
2021-11-19 11:36:50 -06:00
|
|
|
echo "${KEY2} doesn't == 'value'"
|
2021-05-06 08:30:12 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-10-18 17:27:28 -05:00
|
|
|
- name: "Write multiline env with UUID to $GITHUB_ENV"
|
|
|
|
run: |
|
|
|
|
echo 'KEY3<<ghadelimiter_b8273c6d-d535-419a-a010-b0aaac240e36' >> $GITHUB_ENV
|
|
|
|
echo value3 >> $GITHUB_ENV
|
|
|
|
echo 'ghadelimiter_b8273c6d-d535-419a-a010-b0aaac240e36' >> $GITHUB_ENV
|
|
|
|
- name: "Check multiline env with UUID to $GITHUB_ENV"
|
|
|
|
run: |
|
|
|
|
if [[ "${KEY3}" != "value3" ]]; then
|
|
|
|
echo "${KEY3} doesn't == 'value3'"
|
|
|
|
exit 1
|
|
|
|
fi
|