Skip to content

Create pipeline to build cookbooks #5

Create pipeline to build cookbooks

Create pipeline to build cookbooks #5

name: generate-mdx-files
on:
pull_request:
branches:
- main
paths:
- 'fern/pages/cookbooks/**/*.mdx'
- 'scripts/build-cookbooks/**/*'
jobs:
run:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Poetry
shell: bash
run: |
pipx install poetry
- name: Install Project Dependencies with Poetry
shell: bash
run: |
poetry install
- name: Run mypy
id: check_mypy
run: |
if grep -q 'mypy' pyproject.toml; then
echo "mypy is specified in pyproject.toml, running..."
poetry run mypy .
echo "mypy_run=true" >> $GITHUB_ENV
else
echo "mypy is not specified in pyproject.toml, exiting."
echo "mypy_run=false" >> $GITHUB_ENV
fi
shell: bash
- name: Build MDX Files
if: env.mypy_run == 'true'
run: poetry run python .github/scripts/build_cookbooks.py
shell: bash
- name: Check for Changes in build-mdx Folder
id: check_changes
shell: bash
run: |
git add fern/pages/cookbooks* # Ensure this path is correct
git diff --cached --exit-code || echo "::set-output name=changes_detected::true"
continue-on-error: true
- name: Commit and Push Changes
if: steps.check_changes.outputs.changes_detected == 'true'
shell: bash
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git commit -m "Update cookbooks"
git push origin HEAD