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..9e71861 --- /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: '[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}} + 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 }} +