Skip to content

Commit 4e0dd04

Browse files
committed
Export environment and share $RUNNER_TEMP with nix and vm
1 parent bb5471e commit 4e0dd04

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

.github/actions/setup-nix/action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ runs:
1616
shell: bash
1717

1818
- id: container
19-
run: echo "id=$(/usr/bin/docker create --workdir "$GITHUB_WORKSPACE" -e GITHUB_ACTIONS=true -e CI=true -v /var/run/docker.sock:/var/run/docker.sock -v "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" --entrypoint sleep ${{ inputs.image }} infinity)" | tee -a "$GITHUB_OUTPUT"
19+
run: echo "id=$(/usr/bin/docker create -v /var/run/docker.sock:/var/run/docker.sock -v "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" -v "$RUNNER_TEMP:$RUNNER_TEMP" --entrypoint sleep ${{ inputs.image }} infinity)" | tee -a "$GITHUB_OUTPUT"
2020
shell: bash
2121

2222
- run: /usr/bin/docker start ${{ steps.container.outputs.id }}
@@ -28,10 +28,14 @@ runs:
2828
- run: /usr/bin/docker inspect --format "{{range .Config.Env}}{{println .}}{{end}}" ${{ steps.container.outputs.id }}
2929
shell: bash
3030

31+
- id: env
32+
run: echo "env=$(env -0 | grep -z -v '^CI=\|^GITHUB_\|^RUNNER_' | sort -z | base64 -w 0)" | tee -a "$GITHUB_OUTPUT"
33+
shell: bash
34+
3135
- run: |
3236
mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash"
3337
#!/bin/bash --
34-
exec /usr/bin/docker exec -i -w "$PWD" ${{ steps.container.outputs.id }} nix-shell --packages ${{ inputs.packages }} --run "exec bash$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}"
38+
exec /usr/bin/docker exec -i ${{ steps.container.outputs.id }} nix-shell --packages ${{ inputs.packages }} --run "$(comm -23z <(env -0 -u PATH | sort -z) <(base64 -d <<< ${{ steps.env.outputs.env }}) | xargs -0 /bin/bash -c 'printf "export %q; " "$@"' --)cd $(printf %q "$PWD") && exec bash$(printf ' %q' "${@:1:$#-1}")" <"${@:$#}"
3539
EOF
3640
shell: bash
3741

.github/actions/setup-vm/action.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,51 +15,58 @@ runs:
1515
if: inputs.os == 'freebsd'
1616
with:
1717
copyback: false
18-
usesh: true
19-
prepare: pkg install -y bash
18+
prepare: pkg install -y bash && chsh -s `which bash` root
2019
run: set -e; ${{ inputs.run }}
2120

2221
- uses: vmactions/openbsd-vm@v1
2322
if: inputs.os == 'openbsd'
2423
with:
2524
copyback: false
26-
usesh: true
27-
prepare: pkg_add bash
25+
prepare: pkg_add bash && chsh -s `which bash` root
2826
run: set -e; ${{ inputs.run }}
2927

3028
- uses: vmactions/netbsd-vm@v1
3129
if: inputs.os == 'netbsd'
3230
with:
3331
copyback: false
34-
usesh: true
32+
prepare: chsh -s `which bash` root
3533
run: set -e; ${{ inputs.run }}
3634

3735
- uses: vmactions/dragonflybsd-vm@v1
3836
if: inputs.os == 'dragonflybsd'
3937
with:
4038
copyback: false
41-
usesh: true
42-
prepare: pkg install -y bash
39+
prepare: pkg install -y bash && chsh -s `which bash` root
4340
run: set -e; ${{ inputs.run }}
4441

4542
- uses: vmactions/solaris-vm@v1
4643
if: inputs.os == 'solaris'
4744
with:
4845
copyback: false
49-
usesh: true
5046
run: set -e; ${{ inputs.run }}
5147

5248
- uses: vmactions/omnios-vm@v1
5349
if: inputs.os == 'omnios'
5450
with:
5551
copyback: false
56-
usesh: true
5752
run: set -e; ${{ inputs.run }}
5853

54+
- run: |
55+
sudo apt-get update
56+
sudo apt-get install -y sshfs
57+
shell: bash
58+
59+
- run: /bin/bash -c 'set -e; while test $# -gt 0; do rm -rf "$1"; mkdir -p "$1"; sshfs -o idmap=user,reconnect,cache=no,dir_cache=no,direct_io,default_permissions "${{ inputs.os }}:$1" "$1"; shift; done' -- "$GITHUB_WORKSPACE" "$RUNNER_TEMP"
60+
shell: bash
61+
62+
- id: env
63+
run: echo "env=$(env -0 | grep -z -v '^CI=\|^GITHUB_\|^RUNNER_' | sort -z | base64 -w 0)" | tee -a "$GITHUB_OUTPUT"
64+
shell: bash
65+
5966
- run: |
6067
mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash"
6168
#!/bin/bash --
62-
exec ssh ${{ inputs.os }} "cd $(printf %q "$PWD") && exec bash$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}"
69+
exec ssh ${{ inputs.os }} "$(comm -23z <(env -0 -u PATH | sort -z) <(base64 -d <<< ${{ steps.env.outputs.env }}) | xargs -0 /bin/bash -c 'printf "export %q; " "$@"' --)cd $(printf %q "$PWD") && exec bash$(printf ' %q' "${@:1:$#-1}")" <"${@:$#}"
6370
EOF
6471
shell: bash
6572

0 commit comments

Comments
 (0)