Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/issue-to-md/scripts/issue_to_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,29 @@
from pathlib import Path
from github import Github
from jinja2 import Environment, FileSystemLoader
from pathlib import Path

def project_root() -> Path:
"""
Return the project root directory.

If the PROJECT_ROOT environment variable is set, its value is used.
Otherwise, fall back to the parent of the parent directory of the feature directory (.github/issue-to-md), which is the working directory in the associated workflow file, as the feature files are located there now.
"""
env_root = os.getenv("PROJECT_ROOT")
return Path(env_root).resolve() if env_root else Path(__file__).resolve().parents[2]

# ─── CONFIGURATION ─────────────────────────────────────────────────────────────
GITHUB_REPOSITORY = os.getenv("GITHUB_REPOSITORY")
ISSUE_NUMBER = int(os.getenv("ISSUE_NUMBER", "0"))
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
UPLOADS_DIR = Path("assets/uploads")
CONTENT_DIR = Path("content")

ROOT = project_root()
UPLOADS_DIR = ROOT / "assets" / "uploads"
CONTENT_DIR = ROOT / "content"
DEBUG = True

if not GITHUB_REPOSITORY or not GITHUB_TOKEN or ISSUE_NUMBER == 0:
if not GITHUB_REPOSITORY or not GITHUB_TOKEN or not ROOT or ISSUE_NUMBER == 0:
missing = [n for n in ["GITHUB_REPOSITORY","GITHUB_TOKEN","ISSUE_NUMBER"] if not os.getenv(n)]
raise RuntimeError(f"Missing required env vars: {', '.join(missing)}")

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/issue-to-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PROJECT_ROOT: ${{ github.workspace }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down