Find the home directory instead of hard-coding it

This should make the `setup-trunk` workflow more container-independent.
This commit is contained in:
Aaron Fenyes 2025-03-30 13:05:20 -07:00
parent 992fb76419
commit df2d45816c

View file

@ -10,5 +10,13 @@ runs:
using: "composite"
steps:
- run: rustup target add wasm32-unknown-unknown
# Forgejo Runner seems to modify the HOME variable when it's running a job
# in a Docker container, so we have to find the home directory another way,
# inspired by this StackOverflow answer:
#
# https://unix.stackexchange.com/a/247582
#
- id: find-home
run: eval echo "home=~$(whoami)" >> $GITHUB_OUTPUT
- run: curl --output - --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail 'https://github.com/trunk-rs/trunk/releases/download/v0.21.12/trunk-x86_64-unknown-linux-gnu.tar.gz' | tar --gunzip --extract --file -
working-directory: /home/circleci/.cargo/bin
working-directory: ${{ steps.find-home.outputs.home }}/.cargo/bin