2024-08-16 23:40:12 +01:00
|
|
|
name: Test, Build and Publish
|
2024-08-14 16:55:23 +01:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
tags:
|
|
|
|
- '*'
|
2024-08-14 17:27:44 +01:00
|
|
|
pull_request:
|
2024-08-14 16:55:23 +01:00
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
env:
|
2024-08-16 23:40:12 +01:00
|
|
|
# Use the github container registry
|
2024-08-14 16:55:23 +01:00
|
|
|
REGISTRY: ghcr.io
|
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
|
2024-08-16 23:40:12 +01:00
|
|
|
|
2024-08-14 16:55:23 +01:00
|
|
|
jobs:
|
2024-08-14 22:49:36 +01:00
|
|
|
|
2024-08-16 23:40:12 +01:00
|
|
|
# Run the tests scripts
|
2024-08-14 22:49:36 +01:00
|
|
|
test:
|
2024-08-25 16:30:50 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2024-08-14 22:49:36 +01:00
|
|
|
steps:
|
2024-08-25 16:30:50 +01:00
|
|
|
- uses: https://github.com/actions/checkout@v4
|
2024-08-14 22:49:36 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Python
|
2024-08-25 16:30:50 +01:00
|
|
|
uses: https://github.com/actions/setup-python@v5
|
2024-08-14 22:49:36 +01:00
|
|
|
with:
|
|
|
|
python-version: 3.11
|
|
|
|
cache: pip
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip install --upgrade pip
|
|
|
|
python -m pip install -r requirements.txt
|
|
|
|
- name: Run tests
|
|
|
|
run: |
|
|
|
|
python tests/test.py
|
|
|
|
|
2024-08-16 23:40:12 +01:00
|
|
|
# Build and push the docker images
|
2024-08-14 19:03:51 +01:00
|
|
|
build-and-push-images:
|
2024-08-25 16:30:50 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2024-08-14 22:49:36 +01:00
|
|
|
needs: test
|
2024-08-14 16:55:23 +01:00
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
attestations: write
|
|
|
|
id-token: write
|
2024-08-16 23:40:12 +01:00
|
|
|
|
2024-08-14 16:55:23 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2024-08-25 16:30:50 +01:00
|
|
|
uses: https://github.com/actions/checkout@v4
|
2024-08-14 16:55:23 +01:00
|
|
|
|
2024-08-14 17:20:08 +01:00
|
|
|
- name: Set up QEMU
|
2024-08-25 16:30:50 +01:00
|
|
|
uses: https://github.com/docker/setup-qemu-action@v3
|
2024-08-14 17:20:08 +01:00
|
|
|
with:
|
2024-08-14 17:36:28 +01:00
|
|
|
platforms: arm32v7/armhf # arm64v8/aarch64 - no current need for arm64
|
2024-08-14 17:20:08 +01:00
|
|
|
|
2024-08-14 16:55:23 +01:00
|
|
|
- name: Log in to the Container registry
|
2024-08-25 16:30:50 +01:00
|
|
|
uses: https://github.com/docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
2024-08-14 16:55:23 +01:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2024-08-14 17:30:02 +01:00
|
|
|
|
2024-08-16 23:40:12 +01:00
|
|
|
# Use docker-container driver for multi-platform builds
|
2024-08-14 17:30:02 +01:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
with:
|
2024-08-16 23:40:12 +01:00
|
|
|
driver: docker-container
|
2024-08-14 17:30:02 +01:00
|
|
|
|
2024-08-14 16:55:23 +01:00
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
|
|
id: meta
|
2024-08-25 16:30:50 +01:00
|
|
|
uses: https://github.com/docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
2024-08-14 16:55:23 +01:00
|
|
|
with:
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=tag
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=pr
|
|
|
|
type=edge,branch=main
|
|
|
|
|
|
|
|
- name: Build and push Docker image
|
|
|
|
id: push
|
2024-08-25 16:30:50 +01:00
|
|
|
uses: https://github.com/docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
2024-08-14 16:55:23 +01:00
|
|
|
with:
|
|
|
|
context: .
|
2024-08-14 17:36:28 +01:00
|
|
|
platforms: linux/arm/v7,linux/amd64 # linux/arm64 no current need for arm64
|
2024-08-14 16:55:23 +01:00
|
|
|
push: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
2024-08-16 23:40:12 +01:00
|
|
|
# Cache to help the step run a little faster
|
2024-08-14 18:34:48 +01:00
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2024-08-14 16:55:23 +01:00
|
|
|
|
|
|
|
- name: Generate artifact attestation
|
2024-08-25 16:30:50 +01:00
|
|
|
uses: https://github.com/actions/attest-build-provenance@v1
|
2024-08-14 16:55:23 +01:00
|
|
|
with:
|
|
|
|
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
|
|
|
subject-digest: ${{ steps.push.outputs.digest }}
|
|
|
|
push-to-registry: true
|
|
|
|
|