1
0
Fork 0
mirror of https://github.com/JasonN3/build-container-installer.git synced 2025-12-25 10:57:55 +01:00

use cache in action

This commit is contained in:
Jason N. 2024-03-06 10:56:10 -06:00
parent 5e9adc91df
commit a9bd5aeb16

View file

@ -40,6 +40,20 @@ inputs:
description: Version of the action container to run description: Version of the action container to run
deprecationMessage: No longer used. github.action_ref replaces the need for this. Will be removed in a future version. deprecationMessage: No longer used. github.action_ref replaces the need for this. Will be removed in a future version.
required: false required: false
enable_cache_dnf:
description: Whether to enable caching for dnf
required: false
default: "true"
enable_cache_skopeo:
description: Whether to enable caching for skopeo
required: false
default: "true"
dnf_cache_key:
description: Overrides the dnf cache key
required: false
skopeo_cache_key:
description: Overrides the skopeo cache key
required: false
additional_templates: additional_templates:
description: Space delimetered list of additional Lorax templates to include description: Space delimetered list of additional Lorax templates to include
required: false required: false
@ -47,12 +61,32 @@ inputs:
runs: runs:
using: composite using: composite
steps: steps:
- name: Load dnf cache
env:
dnf_cache_key: dnf-${{ inputs.version }}
if: inputs.enable_cache_dnf == 'true'
uses: action/cache/restore@v4
with:
path: /cache/dnf
key: ${{ inputs.dnf_cache_key || env.dnf_cache_key }}
- name: Load skopeo cache
env:
skopeo_cache_key: skopeo-${{ inputs.image_name }}-${{ inputs.image_tag }}
if: inputs.enable_cache_skopeo == 'true'
uses: action/cache/restore@v4
with:
path: /cache/skopeo
key: ${{ inputs.skopeo_cache_key || env.skopeo_cache_key }}
- name: Run docker image - name: Run docker image
shell: bash shell: bash
run: | run: |
# Check if running inside of the action repo # Check if running inside of the action repo
if [[ -z "${{ github.action_ref }}" ]]; then if [[ "${{ github.ref_name }}" =~ (.*)/merge ]]; then tag=pr-${BASH_REMATCH[1]}; else tag=${{ github.ref_name }}; fi; fi if [[ -z "${{ github.action_ref }}" ]]; then if [[ "${{ github.ref_name }}" =~ (.*)/merge ]]; then tag=pr-${BASH_REMATCH[1]}; else tag=${{ github.ref_name }}; fi; fi
if [[ -z "${tag}" ]]; then tag=${{ github.action_ref }}; fi if [[ -z "${tag}" ]]; then tag=${{ github.action_ref }}; fi
if [[ "${{ inputs.enable_cache_dnf }}" == "true" ]]; then cache="${cache} -v /cache/dnf:/cache/dnf"; fi
if [[ "${{ inputs.enable_cache_skopeo }}" == "true" ]]; then cache="${cache} -v /cache/skopeo:/cache/skopeo"; fi
docker run --privileged --volume ${{ github.workspace }}:/github/workspace/ ghcr.io/jasonn3/build-container-installer:${tag} \ docker run --privileged --volume ${{ github.workspace }}:/github/workspace/ ghcr.io/jasonn3/build-container-installer:${tag} \
ARCH=${{ inputs.arch }} \ ARCH=${{ inputs.arch }} \
IMAGE_NAME=${{ inputs.image_name }} \ IMAGE_NAME=${{ inputs.image_name }} \
@ -63,5 +97,24 @@ runs:
WEB_UI=${{ inputs.web_ui }} \ WEB_UI=${{ inputs.web_ui }} \
ENROLLMENT_PASSWORD=${{ inputs.enrollment_password }} \ ENROLLMENT_PASSWORD=${{ inputs.enrollment_password }} \
SECURE_BOOT_KEY_URL=${{ inputs.secure_boot_key_url }} \ SECURE_BOOT_KEY_URL=${{ inputs.secure_boot_key_url }} \
"ADDITIONAL_TEMPLATES=${{ inputs.additional_templates }}" "ADDITIONAL_TEMPLATES=${{ inputs.additional_templates }}" \
DNF_CACHE=/cache/dnf
- name: Save dnf cache
env:
dnf_cache_key: dnf-${{ inputs.version }}
if: inputs.enable_cache_dnf == 'true'
uses: action/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'
uses: action/cache/save@v4
with:
path: /cache/skopeo
key: ${{ inputs.skopeo_cache_key || env.skopeo_cache_key }}