Skip to content

Accept if a file is linked in it's folder's README #157

Accept if a file is linked in it's folder's README

Accept if a file is linked in it's folder's README #157

name: All new examples are linked in the README
on:
pull_request:
branches: [ main ]
jobs:
new-example-links-in-examples-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: |
examples/*.ipynb
- name: Check README links
env:
NEW_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
README: examples/README.md
run: |
echo "$NEW_FILES";
# if [[ -f new_example_files.txt ]]; then
# all_linked=true
# while IFS= read -r file; do
# # Get the directory of the new example file
# example_dir=$(dirname "$file")
# # Get the filename without the directory path
# filename=$(basename "$file")
# # Check if link exists in examples/README.md
# if ! grep -q "$file" examples/README.md && ! grep -q "${file/examples\//](}" examples/README.md; then
# # Check if a README.md exists in the sub-folder, and if so, check for the link there
# if [[ -f "$example_dir/README.md" ]]; then
# if ! grep -q "$filename" "$example_dir/README.md" && ! grep -q "$filename" "$example_dir/README.md"; then
# all_linked=false
# echo "Link to '$file' not found in examples/README.md or $example_dir/README.md"
# echo "::warning file=$file::Link to '$file' not found in a README.md, please add one"
# fi
# else
# all_linked=false
# echo "Link to '$file' not found in examples/README.md, and no README.md found in $example_dir"
# echo "::warning file=$file::Link to '$file' not found in examples/README.md, please add one (or create a README.md in the sub-folder)"
# fi
# fi
# done < new_example_files.txt
# if ! $all_linked; then
# exit 1
# fi
# fi