Fixing issue with format code snippets pipeline #357
Workflow file for this run
This file contains 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: check-python-code-snippets | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- 'fern/pages/**/*.mdx' | |
- 'fern/pages/**/**/*.mdx' | |
jobs: | |
run: | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- 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 Python MDX Snippet Formatter | |
shell: bash | |
run: poetry run python .github/scripts/check_python_code_snippets.py fern/pages | |
- name: Check for changes | |
id: diff | |
run: | | |
git diff --exit-code || echo "::set-output name=changes::true" | |
# Commit and push changes if there are any changes | |
- name: Commit and push changes | |
if: steps.diff.outputs.changes == 'true' | |
uses: stefanzweifel/git-auto-commit-action@v5.1.0 | |
with: | |
commit_message: Check python code snippets | |
commit_user_email: action@github.com | |
commit_user_name: "Github actions" | |
file_pattern: './*.mdx' # Adjust this pattern to match the files you expect to change | |
skip_fetch: true | |
# Upload git diff as a patch file if there are changes and some failure | |
- name: Upload git diff as a patch file | |
if: failure() && steps.diff.outputs.changes == 'true' | |
uses: actions/upload-artifact@v4.6.0 | |
with: | |
name: fern-updates | |
path: fern-updates.patch |