@@ -35,6 +35,10 @@ set -x
35
35
CALLBACK_URL="{{ .CallbackURL }}"
36
36
METADATA_URL="{{ .MetadataURL }}"
37
37
BEARER_TOKEN="{{ .CallbackToken }}"
38
+ {{- if .ExtraContext.OFS_DIR }}
39
+ OFS_DIR_E="{{ .ExtraContext.OFS_DIR }}"
40
+ {{- end }}
41
+ OFS_DIR=${OFS_DIR_E:-"/opt/work"}
38
42
39
43
if [ -z "$METADATA_URL" ];then
40
44
echo "no token is available and METADATA_URL is not set"
@@ -126,8 +130,16 @@ if [ -z "$CACHED_RUNNER" ];then
126
130
sudo ./bin/installdependencies.sh || fail "failed to install dependencies"
127
131
else
128
132
sendStatus "using cached runner found in $CACHED_RUNNER"
129
- sudo cp -a "$CACHED_RUNNER" "/home/{{ .RunnerUsername }}/actions-runner"
130
- sudo chown {{ .RunnerUsername }}:{{ .RunnerGroup }} -R "/home/{{ .RunnerUsername }}/actions-runner" || fail "failed to change owner"
133
+ OFS_AVAIL=1
134
+ RUN_HOME="/home/{{ .RunnerUsername }}/actions-runner"
135
+ sudo mkdir -p $OFS_DIR/upper-layer $OFS_DIR/work-layer $RUN_HOME
136
+ sudo chown {{ .RunnerUsername }}:{{ .RunnerGroup }} -R $OFS_DIR/upper-layer $OFS_DIR/work-layer $CACHED_RUNNER $RUN_HOME
137
+ sudo mount -t overlay overlay -o lowerdir=$CACHED_RUNNER,upperdir=$OFS_DIR/upper-layer,workdir=$OFS_DIR/work-layer $RUN_HOME || OFS_AVAIL=0
138
+ if [ $OFS_AVAIL -eq 0 ];then
139
+ sendStatus "falling back to non-overlayfs mode"
140
+ sudo cp -a "$CACHED_RUNNER/." $RUN_HOME || fail "failed to copy cached runner"
141
+ sudo chown {{ .RunnerUsername }}:{{ .RunnerGroup }} -R "$RUN_HOME" || fail "failed to change owner"
142
+ fi
131
143
cd /home/{{ .RunnerUsername }}/actions-runner
132
144
fi
133
145
0 commit comments