Dependency Digest #25
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: Dependency Digest | |
| on: | |
| schedule: | |
| - cron: "0 7 * * 1" | |
| workflow_dispatch: | |
| permissions: | |
| issues: write | |
| pull-requests: read | |
| jobs: | |
| weekly-digest: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Build and publish digest issue | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const title = "Dependency update digest"; | |
| const pulls = await github.paginate(github.rest.pulls.list, { | |
| owner, | |
| repo, | |
| state: "open", | |
| per_page: 100, | |
| }); | |
| const dependabotPulls = pulls.filter( | |
| (pr) => pr.user?.login === "dependabot[bot]" | |
| ); | |
| const lines = []; | |
| lines.push(`# Dependency update digest`); | |
| lines.push(""); | |
| lines.push(`Updated: ${new Date().toISOString()}`); | |
| lines.push(""); | |
| if (dependabotPulls.length === 0) { | |
| lines.push("No open Dependabot pull requests."); | |
| } else { | |
| lines.push(`Open Dependabot pull requests: ${dependabotPulls.length}`); | |
| lines.push(""); | |
| lines.push("| PR | Title | Labels |"); | |
| lines.push("|---|---|---|"); | |
| for (const pr of dependabotPulls) { | |
| const labels = (pr.labels || []).map((l) => l.name).join(", "); | |
| lines.push(`| #${pr.number} | ${pr.title.replace(/\|/g, "\\|")} | ${labels} |`); | |
| } | |
| } | |
| const body = lines.join("\n"); | |
| const issues = await github.paginate(github.rest.issues.listForRepo, { | |
| owner, | |
| repo, | |
| state: "open", | |
| creator: "github-actions[bot]", | |
| per_page: 100, | |
| }); | |
| const existing = issues.find((issue) => issue.title === title && !issue.pull_request); | |
| if (existing) { | |
| await github.rest.issues.update({ | |
| owner, | |
| repo, | |
| issue_number: existing.number, | |
| body, | |
| }); | |
| core.info(`Updated issue #${existing.number}`); | |
| } else { | |
| const created = await github.rest.issues.create({ | |
| owner, | |
| repo, | |
| title, | |
| body, | |
| labels: ["dependencies"], | |
| }); | |
| core.info(`Created issue #${created.data.number}`); | |
| } |