[Fixes #2] Publish container to ghcr.io #8
Workflow file for this run
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: CI | |
on: | |
push: | |
tags: | |
- v* | |
branches: | |
- master | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
compile: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Retrieve cache | |
id: cache-key | |
uses: actions/cache@v3 | |
with: | |
path: packer-plugin-cross | |
key: key-${{ github.sha }}-1 | |
- name: Checkout | |
if: steps.cache-key.outputs.cache-hit != 'true' | |
uses: actions/checkout@v4.1.1 | |
- name: Set up Go 1.21 | |
if: steps.cache-key.outputs.cache-hit != 'true' | |
uses: actions/setup-go@v5.0.0 | |
with: | |
go-version: '1.21' | |
id: go | |
- name: Get dependencies | |
if: steps.cache-key.outputs.cache-hit != 'true' | |
run: | | |
go get -v -t -d ./... | |
if [ -f Gopkg.toml ]; then | |
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | |
dep ensure | |
fi | |
- name: Build | |
if: steps.cache-key.outputs.cache-hit != 'true' | |
run: go build -v . | |
- name: Cache binary | |
if: steps.cache-key.outputs.cache-hit != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: packer-plugin-cross | |
key: key-${{ github.sha }}-1 | |
test: | |
needs: compile | |
strategy: | |
fail-fast: false | |
matrix: | |
boards: | |
#- bananapi-r1/archlinuxarm.json | |
- beaglebone-black/angstrom.json | |
- beaglebone-black/archlinuxarm.json | |
- beaglebone-black/debian.json | |
- beaglebone-black/ubuntu.pkr.hcl | |
#- jetson-nano/ubuntu.json | |
- odroid-u3/archlinuxarm.json | |
- odroid-xu4/archlinuxarm.json | |
- odroid-xu4/ubuntu.json | |
- parallella/archlinuxarm.json | |
- parallella/ubuntu.json | |
- raspberry-pi/archlinuxarm.json | |
- raspberry-pi/raspbian.json | |
- raspberry-pi/raspbian-resize.json | |
- raspberry-pi/raspios-lite-arm.json | |
- raspberry-pi-3/archlinuxarm.json | |
- raspberry-pi-3/raspios-lite-arm64.json | |
- raspberry-pi-4/ubuntu_server_20.04_arm64.json | |
- raspberry-pi-4/ubuntu_server_20.04_arm64.pkr.hcl | |
- raspberry-pi-4/archlinuxarm.pkr.hcl | |
- rock-4b/debos-radxa.pkr.hcl | |
- wandboard/archlinuxarm.json | |
name: Build ${{ matrix.boards }} image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4.1.1 | |
- name: Fetch additional packages | |
run: | | |
sudo apt-get update | |
sudo apt-get install fdisk gdisk qemu-user-static libarchive-tools tar qemu qemu-utils | |
- name: Install Packer | |
uses: hashicorp-contrib/setup-packer@v3 | |
with: | |
packer-version: 1.10.0 | |
- name: Retrieve cache | |
uses: actions/cache@v3 | |
with: | |
path: packer-plugin-cross | |
key: key-${{ github.sha }}-1 | |
- name: Install packer plugins | |
if: ${{ endsWith(matrix.boards, '.hcl') }} | |
run: PACKER_LOG=1 packer init boards/${{ matrix.boards }} | |
- name: Validate | |
run: PACKER_LOG=1 packer validate boards/${{ matrix.boards }} | |
- name: Build image | |
run: sudo PACKER_LOG=1 packer build boards/${{ matrix.boards }} | |
test-vagrant: | |
needs: compile | |
runs-on: macos-12 | |
name: Build board with vagrant | |
steps: | |
- name: Check GitHub Status | |
uses: crazy-max/ghaction-github-status@v4 | |
- uses: actions/checkout@v4.1.1 | |
- name: Cache Vagrant boxes | |
uses: actions/cache@v3 | |
with: | |
path: ~/.vagrant.d/boxes | |
key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }} | |
restore-keys: | | |
${{ runner.os }}-vagrant- | |
- name: Show Vagrant version | |
run: vagrant --version | |
- name: Install Vagrant plugins | |
run: | | |
vagrant plugin install vagrant-disksize | |
- name: Run vagrant up | |
run: | | |
vagrant up | |
- name: Upload source | |
run: | | |
git archive -o repo.tar.gz HEAD | |
vagrant upload repo.tar.gz /home/vagrant/repo.tar.gz | |
vagrant ssh -c " \ | |
rm -rf packer-plugin-cross && \ | |
mkdir packer-plugin-cross && \ | |
tar -xf repo.tar.gz -C packer-plugin-cross \ | |
" | |
- name: Retrieve cache | |
uses: actions/cache@v3 | |
with: | |
path: packer-plugin-cross | |
key: key-${{ github.sha }}-1 | |
- name: Upload packer-build-arm binary | |
run: | | |
vagrant upload packer-plugin-cross /home/vagrant/packer-plugin-cross/packer-plugin-cross | |
- name: Build board | |
run: | | |
vagrant ssh -c " \ | |
cd packer-plugin-cross && \ | |
sudo PACKER_LOG=1 packer build boards/raspberry-pi-3/archlinuxarm.json \ | |
" | |
- name: Check result | |
run: | | |
vagrant ssh -c "ls -al packer-plugin-cross/raspberry-pi-3.img" | |
plugin-check: | |
needs: compile | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v3.3.1 | |
with: | |
go-version: 1.19 | |
- name: Retrieve cache | |
uses: actions/cache@v3 | |
with: | |
path: packer-plugin-cross | |
key: key-${{ github.sha }}-1 | |
- name: check | |
run: | | |
make plugin-check |