Update GitHub Repos #38
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 GitHub Repos | |
| on: | |
| # Run daily at 2 AM UTC | |
| schedule: | |
| - cron: '0 2 * * *' | |
| # Allow manual trigger | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| actions: write | |
| pages: write | |
| jobs: | |
| update-repos: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Update repo list | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| pwsh -NoProfile -ExecutionPolicy Bypass -File tools/update-github-repos.ps1 -User Bananz0 -Token ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check for changes | |
| id: git-check | |
| run: | | |
| git diff --exit-code _data/github_repos.json || echo "changed=true" >> $GITHUB_OUTPUT | |
| - name: Commit and push if changed | |
| if: steps.git-check.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add _data/github_repos.json | |
| git commit -m "chore: update GitHub repos list [skip ci]" | |
| git push | |
| - name: Trigger Pages deploy | |
| if: steps.git-check.outputs.changed == 'true' | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'jekyll.yml', | |
| ref: 'main' | |
| }) |