Skip to content

fix(GitHub): Fixed problem causing release docker images to be skipped #7

fix(GitHub): Fixed problem causing release docker images to be skipped

fix(GitHub): Fixed problem causing release docker images to be skipped #7

name: Test and Docker
on: [push, pull_request, workflow_dispatch]
env:
GITHUB_OWNER: 'moodlehq'
REPOSITORY: 'wiki-rag'
jobs:
Check-and-Test:
name: Checks and tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- python: '3.12'
- python: '3.13'
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: "**/pyproject.toml"
- name: Install dependencies
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install .[dev]
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
- name: Run pre-commit
run: pre-commit run --all
Build-and-Publish:
name: Docker build and publish
# Need checks and tests to be passing.
needs: Check-and-Test
# Completely avoid forks and pull requests to try any docker job. Only upstream repo push, main branch or tags.
if: |
github.repository_owner == 'moodlehq' &&
contains(fromJson('["push"]'), github.event_name) &&
(
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/tags/v')
)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for tags (we need that for setuptools-scm to find the version)
- name: Calculate image tags and labels
id: calculatetags
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ env.GITHUB_OWNER }}/${{ env.REPOSITORY }}
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish to GitHub registry
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
provenance: false
tags: ${{ steps.calculatetags.outputs.tags }}
labels: ${{ steps.calculatetags.outputs.labels }}
annotations: ${{ steps.calculatetags.outputs.annotations }}