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-25 21:16:25 +01:00
|
|
|
REGISTRY: forge.mdiluz.io
|
2024-08-25 16:35:27 +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:35:27 +01:00
|
|
|
- uses: actions/checkout@v4
|
2024-08-14 22:49:36 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Python
|
2024-08-25 16:35:27 +01:00
|
|
|
uses: actions/setup-python@v5
|
2024-08-14 22:49:36 +01:00
|
|
|
with:
|
2024-08-25 16:35:27 +01:00
|
|
|
python-version: 3.12
|
2024-08-14 22:49:36 +01:00
|
|
|
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-16 23:40:12 +01:00
|
|
|
|
2024-08-14 16:55:23 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2024-08-25 16:35:27 +01:00
|
|
|
uses: actions/checkout@v4
|
2024-08-14 16:55:23 +01:00
|
|
|
|
|
|
|
- name: Log in to the Container registry
|
2024-08-25 16:35:27 +01:00
|
|
|
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
2024-08-14 16:55:23 +01:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
2024-08-25 21:16:25 +01:00
|
|
|
username: ${{ env.GITHUB_ACTOR }}
|
|
|
|
password: ${{ secrets.PACKAGE_PAT }}
|
2024-08-14 17:30:02 +01:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
2024-08-14 16:55:23 +01:00
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
|
|
id: meta
|
2024-08-25 16:35:27 +01:00
|
|
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
2024-08-14 16:55:23 +01:00
|
|
|
with:
|
2024-08-25 21:16:25 +01:00
|
|
|
images: ${{ env.REGISTRY }}/${{ env.GITHUB_REPOSITORY }}
|
2024-08-14 16:55:23 +01:00
|
|
|
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:35:27 +01:00
|
|
|
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
2024-08-14 16:55:23 +01:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|