Skip to content

Commit f013611

Browse files
authored
Restores the tar command to its original state (#21)
### What This PR tries to reduce side effects by: - Restores the `tar` command to its original state - Narrow the ~/.cache directory to just nix and devbox ### Why We are using `chmod u+s "$(command -v tar)"` to setuid on tar (This is needed because we are caching `/nix/` and other directories outside of `~`, which is owned by `root`) This has a problem where it changes the parent directory of `~/.cache/nix` to be owned by `root` instead of `runner`. I thought #22 had fixed it, but we ran into similar issues when we use a go cache on top of the devbox cache. ### Caveat Cache enabled on self hosted Linux may stop working
1 parent c1d7077 commit f013611

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

action.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,12 @@ runs:
100100
echo "#!/bin/sh" >> /usr/local/bin/gtar
101101
echo 'exec sudo /usr/local/bin/gtar.orig "$@"' >> /usr/local/bin/gtar
102102
sudo chmod +x /usr/local/bin/gtar
103-
else
104-
sudo chmod u+s "$(command -v tar)"
103+
elif [ "$RUNNER_OS" == "Linux" ]; then
104+
mkdir -p ~/.cache
105+
mkdir -p ~/.local/bin
106+
echo "#!/bin/sh" >> ~/.local/bin/tar
107+
echo 'exec sudo /usr/bin/tar "$@"' >> ~/.local/bin/tar
108+
sudo chmod +x ~/.local/bin/tar
105109
fi
106110
107111
- name: Configure nix access-tokens
@@ -122,7 +126,8 @@ runs:
122126
uses: actions/cache@v3
123127
with:
124128
path: |
125-
~/.cache
129+
~/.cache/devbox
130+
~/.cache/nix
126131
~/.local/state/nix
127132
~/.nix-defexpr
128133
~/.nix-profile
@@ -134,3 +139,13 @@ runs:
134139
shell: bash
135140
run: |
136141
devbox run --config=${{ inputs.project-path }} -- echo "Packages installed!"
142+
143+
- name: Restore tar command
144+
if: inputs.enable-cache == 'true'
145+
shell: bash
146+
run: |
147+
if [ "$RUNNER_OS" == "macOS" ]; then
148+
sudo mv /usr/local/bin/gtar.orig /usr/local/bin/gtar
149+
elif [ "$RUNNER_OS" == "Linux" ]; then
150+
rm ~/.local/bin/tar
151+
fi

0 commit comments

Comments
 (0)