Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Other cache options
  • Loading branch information
catks committed Mar 12, 2024
commit 07f4996a92d4a2b213bcf87285b9dd0f78aa67fc
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ inputs:
description: "Where the cache is stored in the docker container. Default: `/root/.cache/go-build`"
cache-id:
default: ''
description: "The id of the cache mount. Default: '' (No id)"
description: "The id of the cache mount. Default: '' (No id option added)"
cache-mode:
default: ''
description: "The mode of the cache mount. Default: '' (No mode option added)"
cache-sharing:
default: ''
description: "The sharing option of the cache mount. Default: '' (No sharing option added)"
scratch-dir:
default: scratch
description: "Where the action is stores some temporary files for its processing. Default: `scratch`"
Expand Down
8 changes: 7 additions & 1 deletion main
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ date --iso=ns | tee "$(read_action_input cache-source)"/buildstamp
cache_mount_id="$(read_action_input cache-id)"
cache_mount_id_string=$(test -n "$cache_mount_id" && echo "id=${cache_mount_id}," || echo '')

cache_mount_mode="$(read_action_input cache-mode)"
cache_mount_mode_string=$(test -n "$cache_mount_mode" && echo "mode=${cache_mount_mode}," || echo '')

cache_mount_sharing="$(read_action_input cache-sharing)"
cache_mount_sharing_string=$(test -n "$cache_mount_sharing" && echo "sharing=${cache_mount_sharing}," || echo '')

cat >"$(read_action_input scratch-dir)"/Dancefile.inject <<EOF
FROM busybox:1
COPY buildstamp buildstamp
RUN --mount=type=cache,${cache_mount_id_string}target="$(read_action_input cache-target)" \
RUN --mount=type=cache,${cache_mount_id_string}${cache_mount_mode_string}${cache_mount_sharing_string}target="$(read_action_input cache-target)" \
--mount=type=bind,source=.,target=/var/dance-cache \
cp -p -R /var/dance-cache/. "$(read_action_input cache-target)" || true
EOF
Expand Down
8 changes: 7 additions & 1 deletion post
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ date --iso=ns | tee "$(read_action_input scratch-dir)"/buildstamp
cache_mount_id="$(read_action_input cache-id)"
cache_mount_id_string=$(test -n "$cache_mount_id" && echo "id=${cache_mount_id}," || echo '')

cache_mount_mode="$(read_action_input cache-mode)"
cache_mount_mode_string=$(test -n "$cache_mount_mode" && echo "mode=${cache_mount_mode}," || echo '')

cache_mount_sharing="$(read_action_input cache-sharing)"
cache_mount_sharing_string=$(test -n "$cache_mount_sharing" && echo "sharing=${cache_mount_sharing}," || echo '')

cat >"$(read_action_input scratch-dir)"/Dancefile.extract <<EOF
FROM busybox:1
COPY buildstamp buildstamp
RUN --mount=type=cache,id=${cache_mount_id_string}target="$(read_action_input cache-target)" \
RUN --mount=type=cache,id=${cache_mount_id_string}${cache_mount_mode_string}${cache_mount_sharing_string}target="$(read_action_input cache-target)" \
mkdir -p /var/dance-cache/ \
&& cp -p -R "$(read_action_input cache-target)"/. /var/dance-cache/ || true
EOF
Expand Down