64 lines
1.8 KiB
YAML
64 lines
1.8 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: ['**']
|
|
tags: ['v*']
|
|
pull_request:
|
|
|
|
jobs:
|
|
test-and-lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.14'
|
|
|
|
- name: Install Poetry
|
|
run: pip install poetry
|
|
|
|
- name: Install dependencies
|
|
run: poetry install
|
|
|
|
- name: Lint with Ruff (PEP-8 & Docstrings)
|
|
run: poetry run ruff check .
|
|
|
|
- name: Run Tests with Coverage
|
|
run: poetry run pytest --cov --cov-report=term-missing --cov-fail-under=80
|
|
|
|
publish-container:
|
|
needs: test-and-lint
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
packages: write
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Prepare Docker Metadata
|
|
id: meta
|
|
run: |
|
|
echo "REGISTRY_HOST=${GITEA_SERVER_URL#*://}" >> $GITHUB_OUTPUT
|
|
echo "IMAGE_NAME=$(echo ${{ gitea.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
|
|
env:
|
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ steps.meta.outputs.REGISTRY_HOST }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.PACKAGES_TOKEN }}
|
|
|
|
- name: Build and Push Docker Image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
${{ steps.meta.outputs.REGISTRY_HOST }}/${{ steps.meta.outputs.IMAGE_NAME }}:latest
|
|
${{ steps.meta.outputs.REGISTRY_HOST }}/${{ steps.meta.outputs.IMAGE_NAME }}:${{ gitea.ref_name }}
|