Build NAV appliance #3344
This file contains hidden or 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 NAV appliance | |
| on: [push, pull_request, workflow_dispatch] | |
| jobs: | |
| packer: | |
| name: "Build appliance using Packer" | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| env: | |
| PACKER_LOG: 1 | |
| PACKER_LOG_PATH: packer_build.log | |
| PACKER_CACHE: .cache/packer | |
| PACKER_GITHUB_API_TOKEN: ${{ secrets.PACKER_GITHUB_API_TOKEN }} | |
| DISTRO: bookworm | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install required packages from Ubuntu | |
| run: | | |
| sudo apt-get install -y virtualbox gnupg | |
| - name: Install Packer | |
| run: | | |
| wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list | |
| sudo apt-get update && sudo apt-get install -y packer | |
| - name: Create packer cache directory | |
| run: | | |
| mkdir -p $PACKER_CACHE | |
| - name: Get ISO checksums | |
| id: get-checksum | |
| run: | | |
| echo "checksum=$(cat "${DISTRO}.json" | jq '.builders[].iso_checksum')" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: "Cache downloaded packer images" | |
| uses: actions/cache/save@v3 | |
| if: always() | |
| id: packer-cache | |
| with: | |
| path: .cache/packer | |
| key: ${{ steps.get-checksum.outputs.checksum }} | |
| - name: Install virtualbox plugin | |
| run: | | |
| packer plugins install github.com/hashicorp/virtualbox | |
| - name: Validate Template | |
| run: | | |
| packer validate "${DISTRO}.json" | |
| - name: Build Appliance Artifact | |
| timeout-minutes: 22 | |
| run: | | |
| packer build "${DISTRO}.json" | |
| - name: Make note of NAV package version installed | |
| id: version | |
| run: | | |
| grep "Unpacking nav" "$PACKER_LOG_PATH" | awk -F '[()]' '{print $2}' > navappliance/version.txt | |
| echo "nav_version=$(cat navappliance/version.txt)" >> $GITHUB_OUTPUT | |
| - name: Create annotated tag | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag --force -a "v${{ steps.version.outputs.nav_version }}" -m "Successfully built with Debian package version ${{ steps.version.outputs.nav_version }}" | |
| git push --force origin "v${{ steps.version.outputs.nav_version }}" | |
| - name: Upload version artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: version | |
| path: navappliance/version.txt | |
| - name: Upload video artifact | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: video | |
| path: | | |
| **/*.webm | |
| - name: Upload appliance artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: navappliance | |
| path: | | |
| navappliance/**/* |