Packer build qemu #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Packer build qemu | |
on: | |
workflow_run: | |
workflows: ["Build and Publish devcontainer image"] | |
types: | |
- completed | |
workflow_dispatch: | |
inputs: | |
glueops_codespace_tag: | |
description: 'Enter the Codespace tag name e.g. v0.60.0' | |
required: false | |
jobs: | |
build: | |
runs-on: codespaces | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Setup packer | |
uses: hashicorp/setup-packer@1aa358be5cf73883762b302a3a03abd66e75b232 # v3.1.0 | |
id: setup | |
with: | |
version: 1.11.2 | |
- name: Generate cloud-init iso | |
run: | | |
sudo apt install genisoimage | |
echo '#cloud-config | |
chpasswd: | |
expire: False | |
users: | |
- {name: debian, password: password, type: text} | |
ssh_pwauth: True' > user-data | |
echo 'instance-id: iid-local01 | |
local-hostname: localhost' > meta-data | |
genisoimage -output ci-data.iso -volid cidata -joliet -rock user-data meta-data | |
- name: Install qemu | |
run: sudo apt-get update && sudo apt-get install qemu-system -y | |
- name: Run packer init | |
id: init | |
run: packer init qemu.pkr.hcl | |
- name: Run packer build | |
id: build | |
run: packer build -var glueops_codespaces_container_tag=${{ inputs.glueops_codespace_tag || github.event.workflow_run.head_branch }} qemu.pkr.hcl | |
- id: install-aws-cli | |
uses: unfor19/install-aws-cli-action@v1 | |
with: | |
version: 2 | |
verbose: false | |
arch: amd64 | |
- name: Split qcow2 image into 1024M files | |
run: | | |
mv images/${{ inputs.glueops_codespace_tag || github.event.workflow_run.head_branch }}.qcow2 .. | |
tar -cvf ${{ inputs.glueops_codespace_tag || github.event.workflow_run.head_branch }}.qcow2 | |
split -b 1024M ${{ inputs.glueops_codespace_tag || github.event.workflow_run.head_branch }}.qcow2.tar ${{ inputs.glueops_codespace_tag || github.event.workflow_run.head_branch }}.qcow2.tar.part_ | |
- name: Upload *.qcow.tar.part_* files to GitHub Releases as an Asset | |
uses: xresloader/upload-to-github-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
file: "*.qcow2.tar.part_*" | |
tags: true | |