name: Check Deleted Workflows on: pull_request: branches: - main types: - opened - synchronize - reopened - ready_for_review workflow_dispatch: jobs: check-deleted-workflows: runs-on: orchestration-platform defaults: run: shell: sh steps: - name: Checkout repository run: | REPO_DIR="repo" REPO_CLONE_URL="https://gitea.dataprovider01.sandbox-cat-dat.simpl-europe.eu/dataprovider01/template-code-location.git" CLONE_USER="${{ secrets.REGISTRY_USERNAME }}" CLONE_PASS="${{ secrets.REGISTRY_PASSWORD }}" if [ -z "${CLONE_USER}" ] || [ -z "${CLONE_PASS}" ]; then echo "Missing REGISTRY_USERNAME or REGISTRY_PASSWORD secret" exit 1 fi rm -rf "${REPO_DIR}" AUTH_HEADER="$(printf '%s:%s' "${CLONE_USER}" "${CLONE_PASS}" | base64 | tr -d '\n')" git clone --depth 0 \ -c "http.extraHeader=Authorization: Basic ${AUTH_HEADER}" \ "${REPO_CLONE_URL}" \ "${REPO_DIR}" - name: Install runtime tools run: | apk add --no-cache bash git python3 py3-pip jq curl pip install --no-cache-dir uv - name: Install project dependencies run: | cd repo uv sync --frozen --no-dev --no-install-package torch - name: Compute deleted workflows/jobs against main run: | cd repo PATH="$PWD/.venv/bin:$PATH" \ BASE_REF="${GITHUB_BASE_REF:-main}" \ HEAD_REF="${GITHUB_HEAD_REF:-HEAD}" \ REPOSITORY_FILE="src/template_code_location/repository.py" \ DIFF_OUTPUT="deleted_workflows.txt" \ FAIL_ON_DELETION="false" \ bash .gitea/workflows/list_jobs.sh - name: Compute active workflows list run: | cd repo PATH="$PWD/.venv/bin:$PATH" \ ONLY_ACTIVE="true" \ REGISTRY_USERNAME="${{ secrets.REGISTRY_USERNAME }}" \ REGISTRY_PASSWORD="${{ secrets.REGISTRY_PASSWORD }}" \ bash .gitea/workflows/check_active_workflows.sh > active_workflows.txt - name: Fail only on overlap with active workflows run: | cd repo if [ ! -s deleted_workflows.txt ]; then echo "No deleted workflows/jobs found." exit 0 fi if [ ! -s active_workflows.txt ]; then echo "Active workflows list is empty; no overlap to block on." exit 0 fi awk 'length($0) > 0' deleted_workflows.txt | sort -u > deleted_normalized.txt awk 'length($0) > 0' active_workflows.txt | sort -u > active_normalized.txt comm -12 deleted_normalized.txt active_normalized.txt > overlapping_workflows.txt if [ -s overlapping_workflows.txt ]; then echo "------------------------------------------------" echo "DELETED ACTIVE WORKFLOWS DETECTED" echo "The following deleted workflows/jobs are currently active:" cat overlapping_workflows.txt echo "------------------------------------------------" exit 1 fi echo "No overlap between deleted workflows/jobs and active workflows."