Skip to content

Harden exec endpoint, add tests, fix shellcheck warnings #13

Harden exec endpoint, add tests, fix shellcheck warnings

Harden exec endpoint, add tests, fix shellcheck warnings #13

name: Build Containers
on:
push:
branches: [main, modernize-base-os]
paths:
- "containers/**"
workflow_dispatch:
inputs:
container:
description: "Container to build (or 'all')"
required: true
default: "all"
type: choice
options:
- all
- airwaves-gateway
- airwaves-manager
env:
REGISTRY: ghcr.io
IMAGE_PREFIX: ghcr.io/airframesio
CONTROL_APP_REPO: airframesio/airwaves-os-control
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
gateway: ${{ steps.filter.outputs.gateway }}
manager: ${{ steps.filter.outputs.manager }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
gateway:
- 'containers/airwaves-gateway/**'
manager:
- 'containers/airwaves-manager/**'
build-gateway:
name: Build airwaves-gateway
needs: [changes]
if: ${{ needs.changes.outputs.gateway == 'true' || github.event.inputs.container == 'all' || github.event.inputs.container == 'airwaves-gateway' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Clone control app
continue-on-error: true
uses: actions/checkout@v4
with:
repository: ${{ env.CONTROL_APP_REPO }}
path: containers/airwaves-gateway/control-app
token: ${{ secrets.CONTROL_APP_TOKEN || secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_PREFIX }}/airwaves-gateway
tags: |
type=sha
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: containers/airwaves-gateway
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-manager:
name: Build airwaves-manager
needs: [changes]
if: ${{ needs.changes.outputs.manager == 'true' || github.event.inputs.container == 'all' || github.event.inputs.container == 'airwaves-manager' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_PREFIX }}/airwaves-manager
tags: |
type=sha
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: containers/airwaves-manager
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
export-images:
name: Export container tarballs (${{ matrix.arch }})
needs: [build-gateway, build-manager]
if: ${{ !failure() && !cancelled() }}
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull and export images
run: |
for image in airwaves-gateway airwaves-manager; do
docker pull --platform "linux/${{ matrix.arch }}" "${{ env.IMAGE_PREFIX }}/${image}:latest" || true
docker save "${{ env.IMAGE_PREFIX }}/${image}:latest" -o "${image}-${{ matrix.arch }}.tar" || true
done
- name: Upload tarballs
uses: actions/upload-artifact@v4
with:
name: container-images-${{ matrix.arch }}
path: "*.tar"
retention-days: 30