Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

action: add -p option mkdir images and fix cache #191

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Changes from all commits
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
27 changes: 18 additions & 9 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
description: 'LVH image version'
required: true
default: '5.10-main'
images-folder-parent:
description: 'Parent folder in which to put the downloaded images'
required: false
default: ''
lvh-version:
description: 'LVH cli version (Docker tag)'
required: true
Expand Down Expand Up @@ -136,24 +140,29 @@ runs:
sudo cp /tmp/.ubuntu-pkgs/*.deb /var/cache/apt/archives/
sudo apt-get -y --no-install-recommends install /tmp/.ubuntu-pkgs/*.deb
sudo kvm-ok
- name: Derive VM image file name
if: ${{ inputs.provision == 'true' }}
id: derive-image-name
shell: bash
run: echo "image-name=$(echo ${{ inputs.image }} | sed 's/\-ci//g')_$(echo ${{ inputs.image-version }} | sed 's/\(.*\)\-\(.*\)/\1/g')" >> $GITHUB_OUTPUT
- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
if: ${{ inputs.provision == 'true' }}
id: cache-lvh-image
with:
path: /images/${{ inputs.image }}_${{ inputs.image-version }}.qcow2.zst
path: ${{ inputs.images-folder-parent }}/images/${{ steps.derive-image-name.outputs.image-name }}.qcow2.zst
key: lvh-image-${{ inputs.image }}_${{ inputs.image-version }}
- name: Derive VM image file name
if: ${{ inputs.provision == 'true' }}
id: derive-image-name
- name: Decompressed cached VM image
if: ${{ inputs.provision == 'true' && steps.cache-lvh-image.outputs.cache-hit == 'true' }}
shell: bash
run: echo "image-name=$(echo ${{ inputs.image }} | sed 's/\-ci//g')_$(echo ${{ inputs.image-version }} | sed 's/\(.*\)\-\(.*\)/\1/g')" >> $GITHUB_OUTPUT
run: zstd -df ${{ inputs.images-folder-parent }}/images/${{ steps.derive-image-name.outputs.image-name }}.qcow2.zst
- name: Fetch VM image
if: ${{ inputs.provision == 'true' && steps.cache-lvh-image.outputs.cache-hit != 'true' }}
shell: bash
run: |
sudo mkdir /images; sudo chmod 777 /images
/bin/lvh images pull --cache quay.io/lvh-images/${{ inputs.image }}:${{ inputs.image-version }} --dir "/"
find /images
sudo mkdir -p ${{ inputs.images-folder-parent }}/images; sudo chmod 777 ${{ inputs.images-folder-parent }}/images
/bin/lvh images pull --cache quay.io/lvh-images/${{ inputs.image }}:${{ inputs.image-version }} --dir "${{ inputs.images-folder-parent }}/"
find ${{ inputs.images-folder-parent }}/images -type f -exec sudo chmod 666 {} +
find ${{ inputs.images-folder-parent }}/images
- name: Start VM
if: ${{ inputs.provision == 'true' }}
shell: bash
Expand All @@ -169,7 +178,7 @@ runs:
extraArgs+=("-p" "${{ inputs.port-forward }}")
fi
sudo touch /tmp/console.log
sudo /bin/lvh run --host-mount=${{ inputs.host-mount }} --image /images/${{ steps.derive-image-name.outputs.image-name }}.qcow2 \
sudo /bin/lvh run --host-mount=${{ inputs.host-mount }} --image ${{ inputs.images-folder-parent }}/images/${{ steps.derive-image-name.outputs.image-name }}.qcow2 \
--daemonize -p ${{ inputs.ssh-port }}:22 --serial-port ${{ inputs.serial-port }} \
--cpu=${{ inputs.cpu }} --mem=${{ inputs.mem }} --cpu-kind ${{ inputs.cpu-kind }} \
--console-log-file /tmp/console.log \
Expand Down
Loading