Update GitHub Dependents #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 Dependents | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 0 * * 0" # Every Sunday at midnight UTC | |
| permissions: {} | |
| jobs: | |
| update-dependents: | |
| permissions: | |
| contents: write | |
| packages: read | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 | |
| - name: Setup vp | |
| uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 | |
| with: | |
| cache: true | |
| - name: Run fetch-github-dependents | |
| run: node tools/fetch-github-dependents.mjs | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Format data | |
| run: vp check --fix | |
| - name: Check for changes | |
| id: git-check | |
| run: | | |
| if git diff --exit-code data/dependents.json; then | |
| echo "No changes detected in dependents.json" | |
| echo "changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Changes detected in dependents.json" | |
| echo "changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | |
| id: app-token | |
| if: steps.git-check.outputs.changes == 'true' | |
| with: | |
| client-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| - uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 | |
| id: cpr | |
| if: steps.git-check.outputs.changes == 'true' | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| branch: auto/update-github-dependents | |
| delete-branch: true | |
| title: "chore: update github dependents" | |
| commit-message: "chore: update github dependents" | |
| add-paths: data/dependents.json | |
| - uses: peter-evans/enable-pull-request-automerge@a660677d5469627102a1c1e11409dd063606628d # v3 | |
| if: steps.cpr.outputs.pull-request-operation == 'created' | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} | |
| merge-method: squash | |
| - name: No changes to commit | |
| if: steps.git-check.outputs.changes != 'true' | |
| run: echo "No changes to commit" |