Skip to content

Commit

Permalink
GitHub action: Better error messages and different default install di…
Browse files Browse the repository at this point in the history
…rectory (#442)
  • Loading branch information
klalumiere authored Nov 11, 2024
1 parent c0fa7c4 commit bf8d0c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ description: GitHub Action to install https://github.com/coveooss/tgf

inputs:
tgf-path:
description: |
Installs the TGF binary to this folder.
The folder will not be added to the PATH, but the defaults are typically already in the path.
description: Installs the TGF binary to this folder.
required: false
default: ${{ runner.os == 'Windows' && '${env:LocalAppData}\Microsoft\WindowsApps' || '/usr/local/bin' }}
default: ${{ runner.os == 'Windows' && '${env:LocalAppData}\Microsoft\WindowsApps' || runner.tool_cache }}
ref:
description: The ref to use to run the install script.
default: ${{ github.action_ref }}
Expand All @@ -23,7 +21,9 @@ runs:
env:
TGF_PATH: ${{ inputs.tgf-path }}
VERSION: ${{ inputs.ref }}
run: curl "https://raw.githubusercontent.com/coveooss/tgf/${VERSION}/get-latest-tgf.sh" | bash
run: |
curl "https://raw.githubusercontent.com/coveooss/tgf/${VERSION}/get-latest-tgf.sh" | bash
echo "$TGF_PATH" >> $GITHUB_PATH
- name: Install TGF (windows)
if: runner.os == 'Windows'
Expand Down
8 changes: 4 additions & 4 deletions get-latest-tgf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ if [ ! -w "${TGF_PATH}" ]; then
echo "Since MacOS Ventura (13.X), $TGF_PATH is owned by 'root'."
echo "You can fix this by either"
echo " 1. Running 'sudo chown -R $(id -un):$(id -gn) $TGF_PATH'."
echo " 2. Setting the TGF_PATH variable to an alternate, writable directory."
echo " 2. Setting the TGF_PATH (GitHub action's parameter 'tgf-path') variable to an alternate, writable directory."
exit 1
fi
echo "Please set the TGF_PATH environment variable to install to an alternate, writeable directory."
echo "Please set the TGF_PATH (GitHub action's parameter 'tgf-path') environment variable to install to an alternate, writeable directory."
exit 1
fi


if ! chmod ugo+w "${TGF_PATH}"; then
echo "Cannot make installation directory ${TGF_PATH} writeable."
echo "Please set the TGF_PATH environment variable to install to an alternate, writeable directory."
echo "Please set the TGF_PATH (GitHub action's parameter 'tgf-path') environment variable to install to an alternate, writeable directory."
exit 1
fi
fi

get_local_tgf_version () {
# The sed regex extracts for example 1.23.2 from "tgf v1.23.2", so as to be comparable to get_latest_tgf_version()
[ -r "${TGF}" ] && TGF_LOCAL_VERSION=$(${TGF} --current-version | sed -E -e 's/^.* v(.*)/\1/')
[ -r "${TGF}" ] && TGF_LOCAL_VERSION=$(${TGF} --help-tgf | grep 'VERSION: ' | sed 's/VERSION: //')
}

get_latest_tgf_version () {
Expand Down

0 comments on commit bf8d0c7

Please sign in to comment.