From 84eaac7b7f0c22194bf956c5f669a633dd0a78be Mon Sep 17 00:00:00 2001 From: ChrisCarini <6374067+ChrisCarini@users.noreply.github.com> Date: Sat, 17 May 2025 08:12:13 -0700 Subject: [PATCH 1/2] Update the cache with GitHub Actions; add dependabot to keep GHA workflows up-to-date. --- .github/dependabot.yml | 8 ++++ .../dependabot-auto-merge-auto-approve.yml | 29 ++++++++++++ .github/workflows/update-github-cache.yml | 46 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/dependabot-auto-merge-auto-approve.yml create mode 100644 .github/workflows/update-github-cache.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5605b6b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + open-pull-requests-limit: 5 + diff --git a/.github/workflows/dependabot-auto-merge-auto-approve.yml b/.github/workflows/dependabot-auto-merge-auto-approve.yml new file mode 100644 index 0000000..9bb2c76 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge-auto-approve.yml @@ -0,0 +1,29 @@ +name: Dependabot - auto-merge & auto-approve +on: pull_request + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + steps: + - name: '[Dependabot] Fetch metadata for PR#${{github.event.pull_request.number}}' + id: metadata + uses: dependabot/fetch-metadata@08eff52bf64351f401fb50d4972fa95b9f2c2d1b # v2.4.0 + with: + github-token: '${{ secrets.GITHUB_TOKEN }}' + + - name: '[Dependabot] Enable auto-merge for PR#${{github.event.pull_request.number}}' + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: '[Depandabot] Approve PR for PR#${{github.event.pull_request.number}}' + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/update-github-cache.yml b/.github/workflows/update-github-cache.yml new file mode 100644 index 0000000..eea6aee --- /dev/null +++ b/.github/workflows/update-github-cache.yml @@ -0,0 +1,46 @@ +name: Update GitHub API Cache + +on: + schedule: + - cron: '0 0 1 * *' # Runs at 00:00 on the 1st of every month + workflow_dispatch: + +jobs: + update-cache: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + + - name: Run api_process.py + run: python api_process.py + + - name: Check for changes + id: git-check + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add js/cached-github-api-response.js + echo "changed=$(git diff --cached --quiet && echo 'false' || echo 'true')" >> $GITHUB_OUTPUT + + - name: Commit and push if changed + if: steps.git-check.outputs.changed == 'true' + run: | + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git + git commit -m "Regenerating cached GitHub API response - $(date +'%Y-%m-%d')" js/cached-github-api-response.js + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + From 8dbf671e62b85a9a534751c6a607a9ee8efc4602 Mon Sep 17 00:00:00 2001 From: Chris Carini <6374067+ChrisCarini@users.noreply.github.com> Date: Sat, 17 May 2025 08:48:23 -0700 Subject: [PATCH 2/2] Update .github/workflows/dependabot-auto-merge-auto-approve.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/dependabot-auto-merge-auto-approve.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-auto-merge-auto-approve.yml b/.github/workflows/dependabot-auto-merge-auto-approve.yml index 9bb2c76..9e71861 100644 --- a/.github/workflows/dependabot-auto-merge-auto-approve.yml +++ b/.github/workflows/dependabot-auto-merge-auto-approve.yml @@ -22,7 +22,7 @@ jobs: PR_URL: ${{github.event.pull_request.html_url}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - name: '[Depandabot] Approve PR for PR#${{github.event.pull_request.number}}' + - name: '[Dependabot] Approve PR for PR#${{github.event.pull_request.number}}' run: gh pr review --approve "$PR_URL" env: PR_URL: ${{github.event.pull_request.html_url}}