Build image (nightly) - jammy #641
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
{ | |
"jobs": { | |
"build-jammy": { | |
"runs-on": "ubuntu-22.04", | |
"steps": [ | |
{ | |
"uses": "actions/checkout@v4" | |
}, | |
{ | |
"uses": "catchpoint/workflow-telemetry-action@v2" | |
}, | |
{ | |
"uses": "Kesin11/actions-timeline@v2" | |
}, | |
{ | |
"uses": "whywaita/setup-lxd@v1" | |
}, | |
{ | |
"name": "Setup distrobuilder", | |
"run": "sudo snap install distrobuilder --classic", | |
"shell": "bash" | |
}, | |
{ | |
"name": "Delete unused file", | |
"run": "sudo rm -rf /opt/\nsudo rm -rf /usr/local/*\nsudo rm -rf /usr/local/.ghcup\nsudo rm -rf /usr/lib/jvm /usr/lib/google-cloud-sdk\nsudo rm -rf /home/runneradmin /home/linuxbrew\nsudo rm -rf /home/runner/runners/*.tar.gz\n# ignore /var/run, snap lxd packages, apt\nsudo ls /var/**/** | grep \":\" | tr -d \":\" | grep -Ev \"/var/run|/var/snap/lxd|/var/lib/snapd|/var/lib/dpkg\" | xargs -I%% sudo rm -rf %%\n# ignore /usr/share/dpkg\nls /usr/share/ | grep -vE \"dpkg|debconf|dbus\" | xargs -I%% sudo rm -rf /usr/share/%%\n\nsudo mkdir -p /opt\nsudo chmod 777 /opt\n", | |
"shell": "bash" | |
}, | |
{ | |
"uses": "hashicorp/setup-packer@main" | |
}, | |
{ | |
"name": "Display storage information", | |
"run": "df -Th", | |
"shell": "bash" | |
}, | |
{ | |
"name": "Clone actions/runner-images", | |
"run": "git clone --depth 1 https://github.com/actions/runner-images\ncd runner-images\nexport DIR=$(pwd)\necho \"dir=${DIR}\" >> $GITHUB_ENV\necho \"virtual-environments-hash=$(git rev-parse --short HEAD)\" >> $GITHUB_ENV\necho \"build-date=$(date '+%Y%m%d')\" >> $GITHUB_ENV\necho \"os-release=$(cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d'=' -f2)\" >> $GITHUB_ENV\n", | |
"shell": "bash" | |
}, | |
{ | |
"if": "${{ env.os-release == '22.04' }}", | |
"name": "Clear duplicate entry in nftables (only jammy)", | |
"run": "# ref: https://discuss.linuxcontainers.org/t/lxdbr0-firewall-problem-with-ubuntu-22-04-host-running-docker-and-lxd/15298/9\nsudo nft flush ruleset\nsudo systemctl restart snap.lxd.daemon\n", | |
"shell": "bash" | |
}, | |
{ | |
"name": "Apply LXD patch", | |
"run": "cp ../lxd.patch .\npatch -p1 < lxd.patch\n", | |
"shell": "bash", | |
"working-directory": "${{ env.dir }}" | |
}, | |
{ | |
"name": "packer init", | |
"run": "packer init images/ubuntu/templates/ubuntu-22.04.pkr.hcl", | |
"shell": "bash", | |
"working-directory": "${{ env.dir }}" | |
}, | |
{ | |
"name": "packer validate packer.json", | |
"run": "packer validate -syntax-only images/ubuntu/templates/ubuntu-22.04.pkr.hcl", | |
"shell": "bash", | |
"working-directory": "${{ env.dir }}" | |
}, | |
{ | |
"env": { | |
"PACKER_LOG": 1 | |
}, | |
"name": "packer build packer.json", | |
"run": "packer build -on-error=abort images/ubuntu/templates/ubuntu-22.04.pkr.hcl", | |
"shell": "bash", | |
"working-directory": "${{ env.dir }}" | |
}, | |
{ | |
"name": "Stop container", | |
"run": "lxc stop packer-lxd", | |
"shell": "bash" | |
}, | |
{ | |
"name": "Remove swap", | |
"run": "sudo swapoff /mnt/swapfile\nsudo rm -rf /mnt/swapfile\n", | |
"shell": "bash" | |
}, | |
{ | |
"name": "Build by distrobuilder", | |
"run": "sudo mkdir -p /mnt/cache\nsudo mkdir -p /mnt/output\nsudo distrobuilder pack-lxd distrobuilder-def.yaml \"/var/snap/lxd/common/lxd/storage-pools/default/containers/packer-lxd\" /mnt/output --cache-dir /mnt/cache\n\nset -x\nls -l /mnt/output\n", | |
"shell": "bash" | |
}, | |
{ | |
"name": "Remove container", | |
"run": "lxc delete packer-lxd", | |
"shell": "bash" | |
}, | |
{ | |
"name": "Upload artifact", | |
"uses": "actions/upload-artifact@v4", | |
"with": { | |
"name": "virtual-environments-lxd-22.04-${{ env.virtual-environments-hash }}-${{ env.build-date }}.zip", | |
"path": "/mnt/output/*", | |
"retention-days": 5 | |
} | |
}, | |
{ | |
"env": { | |
"SLACK_WEBHOOK_TYPE": "INCOMING_WEBHOOK", | |
"SLACK_WEBHOOK_URL": "${{ secrets.SLACK_WEBHOOK_URL }}" | |
}, | |
"name": "Notify", | |
"uses": "slackapi/slack-github-action@v1", | |
"with": { | |
"payload": "{\n \"blocks\": [\n {\n \"type\": \"section\",\n \"text\": {\n \"type\": \"mrkdwn\",\n \"text\": \"Build actions-image-runner-lxd ${{ github.workflow }} is ${{ job.status }}\"\n }\n },\n {\n \"type\": \"section\",\n \"fields\": [\n {\n \"type\": \"mrkdwn\",\n \"text\": \"*Repository*: <https://github.com/whywaita/actions-runner-images-lxd|whywaita/actions-runner-images-lxd>\"\n },\n {\n \"type\": \"mrkdwn\",\n \"text\": \":arrow_right: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View action>\"\n }\n ]\n }\n ]\n}\n" | |
} | |
} | |
] | |
} | |
}, | |
"name": "Build image (nightly) - jammy", | |
"on": { | |
"schedule": [ | |
{ | |
"cron": "0 22 * * *" | |
} | |
], | |
"workflow_dispatch": { } | |
} | |
} |