Update Examples Context #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Examples Context | |
on: | |
workflow_dispatch: # Manually triggered via GitHub Actions UI | |
repository_dispatch: | |
types: [examples-context-update] | |
jobs: | |
build-examples: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
steps: | |
- name: Checkout This Repo | |
uses: actions/checkout@v4 | |
- name: Install yq | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y yq | |
- name: Parse Configuration | |
id: parse_config | |
run: | | |
# Read from config.yaml (examples_context) with fallback defaults | |
CLONE_URL=$(yq '.examples_context.clone_url // "https://github.com/your-username/your-notebook-repo"' config.yaml) | |
CLONE_DIR=$(yq '.examples_context.clone_dir // "examples_source"' config.yaml) | |
SCRIPT_PATH=$(yq '.examples_context.script_path // "context_examples/process_examples.py"' config.yaml) | |
BRANCH_NAME=$(yq '.examples_context.branch_name // "examples-md-update"' config.yaml) | |
COMMIT_MESSAGE=$(yq '.examples_context.commit_message // "Add combined Markdown output for examples context"' config.yaml) | |
OUTPUT_FILE=$(yq '.examples_context.output_file // "videodb_helper/context_examples/context/index_ipynb.md"' config.yaml) | |
echo "clone_url=$CLONE_URL" >> $GITHUB_OUTPUT | |
echo "clone_dir=$CLONE_DIR" >> $GITHUB_OUTPUT | |
echo "script_path=$SCRIPT_PATH" >> $GITHUB_OUTPUT | |
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT | |
echo "output_file=$OUTPUT_FILE" >> $GITHUB_OUTPUT | |
- name: Clone Examples Repo | |
run: git clone ${{ steps.parse_config.outputs.clone_url }} ${{ steps.parse_config.outputs.clone_dir }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Create Virtual Environment | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
pip install --upgrade pip | |
- name: Install Dependencies Using pyproject.toml | |
run: | | |
source venv/bin/activate | |
# Installs dependencies as specified in your pyproject.toml (assumed to be at repo root) | |
pip install . | |
- name: Run Examples Processing | |
run: | | |
source venv/bin/activate | |
export PYTHONPATH=$PYTHONPATH:$(pwd) | |
python ${{ steps.parse_config.outputs.script_path }} | |
- name: Remove Cloned Repository | |
run: rm -rf ${{ steps.parse_config.outputs.clone_dir }} | |
- name: Commit and Push Combined MD | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout -b ${{ steps.parse_config.outputs.branch_name }} | |
git add ${{ steps.parse_config.outputs.output_file }} | |
git commit -m ${{ steps.parse_config.outputs.commit_message }} | |
git push --force --set-upstream origin ${{ steps.parse_config.outputs.branch_name }} | |
- name: Create Pull Request | |
run: | | |
gh pr create \ | |
--base main \ | |
--head ${{ steps.parse_config.outputs.branch_name }} \ | |
--title ${{ steps.parse_config.outputs.commit_message }} \ | |
--body "This PR adds the simplified Markdown output from the example notebooks." || true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |