name: Build
on:
workflow_dispatch:
workflow_call:
push:
branches: [ main ]
tags: [ "v*.*.*" ]
# # Allow other repositories to trigger this workflow via repository_dispatch
# repository_dispatch:
# types: [main-push]
# pull_request:
jobs:
tests:
name: ✅ Run tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# os: ["ubuntu-latest", "windows-latest", "macos-latest"]
os: ["ubuntu-latest"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies with UV
run: uv sync --extra agent
- name: Lint
run: uvx ruff check
- name: Format
run: uvx ruff format --check
- name: Type check
run: uv run mypy
- name: Start server
run: |
SERVER_PORT=8001 OPENSEARCH_URL=http://localhost:9200 uv run uvicorn src.data_commons_search.main:app --host 0.0.0.0 --port 8001 --log-config logging.yml --reload &
sleep 10
- name: Run tests
run: uv run pytest
docker:
name: 🐳 Build Docker image
runs-on: ubuntu-latest
# needs: test
permissions:
contents: read
packages: write
outputs:
image-digest: ${{ steps.build.outputs.digest }}
image-metadata: ${{ steps.meta.outputs.json }}
steps:
- uses: actions/checkout@v5
- name: Checkout frontend repo
uses: actions/checkout@v5
with:
repository: EOSC-Data-Commons/eoscdcpoc
path: eoscdcpoc
# If this workflow was triggered by a tag, use that tag to check out the frontend repo
ref: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'main' }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
- name: Build frontend
run: |
cd eoscdcpoc
npm ci
npm run build
rm -rf ../src/data_commons_search/webapp/
cp -R dist/spa/ ../src/data_commons_search/webapp/
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/eosc-data-commons/data-commons-search
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# outputs: type=image,name=ghcr.io/eosc-data-commons/data-commons-search,push-by-digest=true,name-canonical=true,push=true
generate-changelog:
name: 🏔️ Generate changelog for the GitHub release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: CHANGES.md
- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGES.md