Skip to content

Commit

Permalink
Elevated permissions for GITHUB_TOKEN to write PRs. Making errors mor…
Browse files Browse the repository at this point in the history
…e pronounced
  • Loading branch information
HowieG committed Sep 18, 2024
1 parent c3b400f commit 781e73f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/add-markdown-examples-to-docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update Docs
name: Add Notebook Examples to Docs

on:
push:
Expand All @@ -7,9 +7,13 @@ on:
paths:
- 'examples/**'
- 'docs/v1/examples/**'

permissions:
contents: write
pull-requests: write

jobs:
add-markdown-examples-to-docs:
add-notebook-examples-to-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -31,23 +35,20 @@ jobs:
echo "Processing file: $file"
source_file=$(grep -oP '(?<=\{/\* SOURCE_FILE: ).*(?= \*/\})' "$file" || true)
if [[ -z "$source_file" ]]; then
echo "No source file found in $file, skipping..."
echo "Error: No source file found in $file, skipping..." >&2
continue
fi
echo "Source file: $source_file"
if [[ -f "$source_file" ]]; then
echo "Converting notebook to markdown"
jupyter nbconvert --to markdown "$source_file" || { echo "Failed to convert $source_file"; continue; }
jupyter nbconvert --to markdown "$source_file" || { echo "Error: Failed to convert $source_file" >&2; continue; }
markdown_file="${source_file%.ipynb}.md"
echo "Appending markdown to $file"
echo -e "\n\n" >> "$file"
cat "$markdown_file" >> "$file" || { echo "Failed to append markdown to $file"; continue; }
echo "Contents of $file after appending markdown:"
cat "$file"
echo "Removing temporary markdown file"
rm "$markdown_file" || { echo "Failed to remove $markdown_file"; continue; }
cat "$markdown_file" >> "$file" || { echo "Error: Failed to append markdown to $file" >&2; continue; }
rm "$markdown_file" || { echo "Error: Failed to remove $markdown_file" >&2; continue; }
else
echo "Source file not found: $source_file"
echo "Error: Source file not found: $source_file" >&2
fi
done
Expand Down

0 comments on commit 781e73f

Please sign in to comment.