Update README from JSON #68
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: Update README from JSON | |
| # This workflow automatically updates the README file whenever the JSON file or the script changes. | |
| on: | |
| push: | |
| paths: | |
| - "awesome_geophysics.json" # Trigger on changes to the JSON file | |
| - "generate_readme.py" # Trigger on changes to the script | |
| workflow_dispatch: # Allow manual triggering of the workflow | |
| schedule: | |
| - cron: "0 0 * * 0" # Run weekly on Sundays at midnight UTC | |
| jobs: | |
| update-readme: | |
| runs-on: ubuntu-latest | |
| # Grant write permissions to the GITHUB_TOKEN | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install dependencies | |
| run: pip install pyyaml | |
| - name: Generate README | |
| run: python scripts/generate_readme.py | |
| - name: Check for changes | |
| id: git-check | |
| run: | | |
| git diff --quiet README.md || echo "changes=true" >> $GITHUB_OUTPUT | |
| - name: Commit and push changes | |
| if: steps.git-check.outputs.changes == 'true' | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add README.md | |
| git commit -m "Auto-update README from JSON [skip ci]" || echo "No changes to commit" | |
| # Use GITHUB_TOKEN for authentication | |
| git push "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" HEAD:main |