From d959ecc6236d90404509bf1c6ac42ef47bb7e0e3 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Sat, 10 Jul 2021 00:11:23 +0200 Subject: [PATCH] Support building for other architectures (#36) --- .github/workflows/test.yml | 8 ++++++++ action.yml | 4 ++++ main.js | 10 ++++++++++ 3 files changed, 22 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e658cd3..8e0f070 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,24 +13,31 @@ jobs: matrix: include: - package: at + arch: amd64 repo: https://salsa.debian.org/debian/at.git ref: debian/3.1.23-1 - package: lolcat + arch: arm64 repo: https://salsa.debian.org/ruby-team/lolcat.git ref: debian/100.0.1-2 - package: micro + arch: amd64 repo: https://salsa.debian.org/go-team/packages/micro.git ref: debian/2.0.6-2_bpo10+1 - package: dropbear + arch: arm64 repo: https://salsa.debian.org/debian/dropbear.git ref: debian/2016.74-5+deb9u1 - package: deber + arch: amd64 repo: https://github.com/dawidd6/deber.git ref: v1.0.0 - package: netcat-openbsd + arch: arm64 repo: https://git.launchpad.net/ubuntu/+source/netcat-openbsd ref: import/1.206-1ubuntu1 - package: iproute2 + arch: amd64 repo: https://git.launchpad.net/ubuntu/+source/iproute2 ref: import/4.18.0-1ubuntu2_ubuntu18.04.1 steps: @@ -41,6 +48,7 @@ jobs: - name: Test run uses: ./ with: + cpu_architecture: ${{matrix.arch}} source_directory: ${{matrix.package}} artifacts_directory: artifacts - name: Check files diff --git a/action.yml b/action.yml index 173700e..b2d4c92 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,10 @@ branding: color: red icon: package inputs: + cpu_architecture: + description: Target CPU architecture + required: false + default: amd64 source_directory: description: Directory where Debian sources are, relative to workspace required: false diff --git a/main.js b/main.js index 9eca515..72d7773 100644 --- a/main.js +++ b/main.js @@ -28,6 +28,7 @@ async function getImageName(distribution) { async function main() { try { + const cpuArchitecture = core.getInput("cpu_architecture") || "amd64" const sourceRelativeDirectory = core.getInput("source_directory") || "./" const artifactsRelativeDirectory = core.getInput("artifacts_directory") || "./" const osDistribution = core.getInput("os_distribution") || "" @@ -67,9 +68,18 @@ async function main() { console.log(details) core.endGroup() + if (cpuArchitecture != "amd64") { + core.startGroup("Install QEMU") + // Need newer QEMU to avoid errors + await exec.exec("wget", ["http://mirrors.kernel.org/ubuntu/pool/universe/q/qemu/qemu-user-static_5.2+dfsg-9ubuntu2_amd64.deb", "-O", "/tmp/qemu.deb"]) + await exec.exec("sudo", ["dpkg", "-i", "/tmp/qemu.deb"]) + core.endGroup() + } + core.startGroup("Create container") await exec.exec("docker", [ "create", + "--platform", `linux/${cpuArchitecture}`, "--name", container, "--volume", workspaceDirectory + ":" + workspaceDirectory, "--workdir", sourceDirectory,