|
| 1 | +name: Packer build qemu |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "feat/add-kvm-acceleration" |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 11 | + runs-on: codespaces |
| 12 | + steps: |
| 13 | + - name: Enable KVM group perms |
| 14 | + run: | |
| 15 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 16 | + sudo udevadm control --reload-rules |
| 17 | + sudo udevadm trigger --name-match=kvm |
| 18 | +
|
| 19 | + - name: Debug Print Ref Info |
| 20 | + run: | |
| 21 | + echo "inputs.glueops_codespace_tag: ${{ inputs.glueops_codespace_tag }}" |
| 22 | + echo "event.workflow_run.head_branch: ${{ github.event.workflow_run.head_branch }}" |
| 23 | + echo "event.workflow_run.head_sha: ${{ github.event.workflow_run.head_sha }}" |
| 24 | + echo "github.ref: ${{ github.ref }}" |
| 25 | + echo "event_name: ${{ github.event_name }}" |
| 26 | + |
| 27 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + ref: ${{ inputs.glueops_codespace_tag || github.event.workflow_run.head_sha }} |
| 31 | + |
| 32 | + - name: Setup packer |
| 33 | + uses: hashicorp/setup-packer@1aa358be5cf73883762b302a3a03abd66e75b232 # v3.1.0 |
| 34 | + id: setup |
| 35 | + with: |
| 36 | + version: 1.11.2 |
| 37 | + |
| 38 | + - name: Generate image password |
| 39 | + run: echo "IMAGE_PASSWORD=$(openssl rand -base64 16)" >> $GITHUB_ENV |
| 40 | + |
| 41 | + - name: Generate cloud-init data |
| 42 | + run: | |
| 43 | + echo '#cloud-config |
| 44 | + chpasswd: |
| 45 | + expire: False |
| 46 | + users: |
| 47 | + - {name: debian, password: '"$IMAGE_PASSWORD"', type: text} |
| 48 | + ssh_pwauth: True' > user-data |
| 49 | + echo '' > meta-data |
| 50 | + |
| 51 | + - name: Install qemu |
| 52 | + run: sudo apt-get update && sudo apt-get install qemu-system -y |
| 53 | + |
| 54 | + - name: Run packer init |
| 55 | + id: init |
| 56 | + run: packer init qemu.pkr.hcl |
| 57 | + |
| 58 | + - name: Run packer build |
| 59 | + id: build |
| 60 | + run: packer build -var glueops_codespaces_container_tag=v0.98.0 -var image_password=${{ env.IMAGE_PASSWORD }} qemu.pkr.hcl |
0 commit comments