Update README and Documentation Links #13
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: Update README and Documentation Links | |
on: | |
workflow_run: | |
workflows: | |
- pages-build-deployment | |
types: | |
- completed | |
jobs: | |
update-links: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Pull latest changes | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git pull --rebase origin main | |
- name: Update README and documentation links | |
run: | | |
# Update links in README.md | |
README_FILE="index.html" | |
if [ -f "$README_FILE" ]; then | |
sed -i 's|\([^ )]*\)\.ipynb|\1.html|g' "$README_FILE" | |
sed -i 's|\([^ )]*\)\.md|\1.html|g' "$README_FILE" | |
fi | |
# Update links in markdown files in documentation folder | |
DOCS_DIR="documentation" | |
if [ -d "$DOCS_DIR" ]; then | |
find "$DOCS_DIR" -name '*.html' -type f | while read -r file; do | |
sed -i 's|\([^ )]*\)\.ipynb|\1.html|g' "$file" | |
sed -i 's|\([^ )]*\)\.md|\1.html|g' "$file" | |
done | |
fi | |
- name: Stage and commit changes | |
run: | | |
git add README.md documentation/*.md | |
if git diff --cached --quiet; then | |
echo "No changes to commit." | |
else | |
git commit -m "Update links to HTML files in README and documentation" | |
git push | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |