From ad1d258e39e47fddd4654a63deea779a4f9e5074 Mon Sep 17 00:00:00 2001 From: "Jason N." <33561705+JasonN3@users.noreply.github.com> Date: Thu, 7 Mar 2024 09:58:25 -0500 Subject: [PATCH] try to cache container image --- Containerfile | 2 +- Makefile | 2 +- action.yml | 31 ++++++++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Containerfile b/Containerfile index 8d93ad4..8504616 100644 --- a/Containerfile +++ b/Containerfile @@ -19,7 +19,7 @@ VOLUME /build-container-installer/repos VOLUME /cache RUN dnf install -y make && make install-deps -RUN ln -s ~/.local/share/containers/cache /cache/skopeo +RUN ln -s /cache/skopeo /build-container-installer/container && mkdir /cache/dnf ENTRYPOINT ["/bin/bash", "/build-container-installer/entrypoint.sh"] diff --git a/Makefile b/Makefile index c59f54f..3fcacdb 100644 --- a/Makefile +++ b/Makefile @@ -190,5 +190,5 @@ test-iso: $(foreach test,$(_TESTS),chmod +x tests/iso/$(test)) $(foreach test,$(_TESTS),./tests/iso/$(test) deploy.iso) -.PHONY: clean install-deps +.PHONY: clean install-deps test-iso container/$(IMAGE_NAME)-$(IMAGE_TAG) diff --git a/action.yml b/action.yml index 0cf99a0..723f491 100644 --- a/action.yml +++ b/action.yml @@ -47,6 +47,13 @@ inputs: dnf_cache_key: description: Overrides the dnf cache key required: false + enable_cache_skopeo: + description: Whether to enable caching for skopeo + required: false + default: "true" + skopeo_cache_key: + description: Overrides the skopeo cache key + required: false additional_templates: description: Space delimetered list of additional Lorax templates to include required: false @@ -61,7 +68,7 @@ runs: sudo chmod 777 /cache - name: Load dnf cache - id: load_cache + id: load_dnf_cache env: dnf_cache_key: dnf-${{ inputs.version }} if: inputs.enable_cache_dnf == 'true' @@ -69,7 +76,16 @@ runs: with: path: /cache/dnf key: ${{ inputs.dnf_cache_key || env.dnf_cache_key }} - restore-keys: ${{ inputs.dnf_cache_key || env.dnf_cache_key }}-${{ github.}} + + - name: Load skopeo cache + id: load_skopeo_cache + env: + skopeo_cache_key: skopeo-${{ inputs.image_name }}-${{ inputs.image_tag }} + if: inputs.enable_cache_skopeo == 'true' + uses: actions/cache/restore@v4 + with: + path: /cache/skopeo + key: ${{ inputs.skopeo_cache_key || env.skopeo_cache_key }} - name: Run docker image shell: bash @@ -94,8 +110,17 @@ runs: - name: Save dnf cache env: dnf_cache_key: dnf-${{ inputs.version }} - if: inputs.enable_cache_dnf == 'true' && steps.load_cache.outputs.cache-hit == 'false' + if: inputs.enable_cache_dnf == 'true' && steps.load_dnf_cache.outputs.cache-hit == 'false' uses: actions/cache/save@v4 with: path: /cache/dnf key: ${{ inputs.dnf_cache_key || env.dnf_cache_key }} + + - name: Save skopeo cache + env: + skopeo_cache_key: skopeo-${{ inputs.image_name }}-${{ inputs.image_tag }} + if: inputs.enable_cache_skopeo == 'true' && steps.load_skopeo_cache.outputs.cache-hit == 'false' + uses: actions/cache/save@v4 + with: + path: /cache/skopeo + key: ${{ inputs.skopeo_cache_key || env.skopeo_cache_key }}