Merge pull request #4 from mattvenn/main #35
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: build_vm | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch | |
push: | |
branches: ['main'] | |
pull_request: | |
branches: ['main'] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Enable KVM group perms | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# this might remove tools that are actually needed, | |
# if set to "true" but frees about 6 GB | |
tool-cache: false | |
- name: Install virtualbox | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y virtualbox | |
- name: Setup `packer` | |
uses: hashicorp/setup-packer@main | |
env: | |
PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Configure packer | |
run: 'packer init ./image.pkr.hcl' | |
- name: 'Write vminfo.json' | |
run: | | |
cat > vminfo.json << EOF | |
{ | |
"repo": "${{ github.server_url }}/${{ github.repository }}", | |
"commit": "${{ github.sha }}", | |
"tag": "${{ github.ref }}", | |
"build_time": "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
} | |
EOF | |
cat vminfo.json | |
- name: Build VM | |
run: 'packer build ./image.pkr.hcl' | |
- name: Copy VM info to output directory | |
run: 'cp vminfo.json output-tinytapeout_analog_vm/tinytapeout_analog_vm.ova.json' | |
- name: Upload VM image | |
uses: actions/upload-artifact@v4 | |
with: | |
name: tt_analog_virtualbox_ova | |
path: | | |
output-tinytapeout_analog_vm/tinytapeout_analog_vm.ova | |
output-tinytapeout_analog_vm/tinytapeout_analog_vm.ova.json | |
publish: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
needs: build | |
steps: | |
- name: Download VM image | |
uses: actions/download-artifact@v4 | |
with: | |
name: tt_analog_virtualbox_ova | |
path: artifacts | |
- name: Generate SHA256 hash | |
working-directory: artifacts | |
run: sha256sum tinytapeout_analog_vm.ova > tinytapeout_analog_vm.ova.sha256 | |
- name: Set up S3cmd cli tool | |
uses: s3-actions/[email protected] | |
with: | |
provider: cloudflare | |
access_key: ${{ secrets.R2_ACCESS_KEY }} | |
secret_key: ${{ secrets.R2_SECRET_KEY }} | |
account_id: ${{ vars.R2_ACCOUNT_ID }} | |
- name: Upload VM image to R2 | |
working-directory: artifacts | |
run: | | |
s3cmd put --multipart-chunk-size-mb=5000 --acl-public tinytapeout_analog_vm.ova tinytapeout_analog_vm.ova.json tinytapeout_analog_vm.ova.sha256 "s3://$BUCKET_NAME/" | |
env: | |
BUCKET_NAME: ${{ vars.R2_BUCKET_NAME }} |