Implement dynamic link loading from JSON #5
This file contains hidden or 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: Generate Links JSON | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| generate-links: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: List folders and create JSON | |
| run: | | |
| # List directories, exclude .github, and create JSON array | |
| folders=$(ls -d */ 2>/dev/null | sed 's|/$||' | grep -v '^\.github$' || true) | |
| if [ -n "$folders" ]; then | |
| json_array=$(echo "$folders" | jq -R . | jq -s .) | |
| echo "$json_array" > links.json | |
| else | |
| echo "[]" > links.json | |
| fi | |
| - name: Commit and push changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add links.json | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "[ci skip] Update links.json with current folders" | |
| git push | |
| fi |