diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..43fc29f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,29 @@ +version: 2 +updates: + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" + time: "04:00" + timezone: "UTC" + open-pull-requests-limit: 10 + rebase-strategy: "auto" + groups: + production-dependencies: + dependency-type: "production" + update-types: ["patch", "minor"] + development-dependencies: + dependency-type: "development" + update-types: ["patch", "minor"] + major-updates: + dependency-type: "production" + update-types: ["major"] + major-development-updates: + dependency-type: "development" + update-types: ["major"] + labels: + - "dependencies" + - "dependabot" + commit-message: + prefix: "chore(deps)" + prefix-development: "chore(deps-dev)" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d68d5e9..bede4e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,10 @@ on: pull_request: push: +permissions: + contents: read + security-events: write + jobs: ci: runs-on: ubuntu-latest @@ -21,6 +25,20 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile + - name: Dependency Security Scan + uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0 + with: + scan-type: 'fs' + ignore-unfixed: true + format: 'sarif' + output: 'trivy-results.sarif' + + - name: Upload Trivy results + if: success() || failure() + uses: github/codeql-action/upload-sarif@7fd177fa680c9881b53cdab4d346d32574c9f7f4 # v3 + with: + sarif_file: 'trivy-results.sarif' + - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml new file mode 100644 index 0000000..40e6fe4 --- /dev/null +++ b/.github/workflows/dependabot-automerge.yml @@ -0,0 +1,42 @@ +name: Dependabot Auto-Merge & Self-Heal + +on: + pull_request_target: + types: [opened, synchronize, reopened] + +permissions: + contents: write + pull-requests: write + checks: read + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Fetch metadata + id: metadata + uses: dependabot/fetch-metadata@v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Auto-approve safe updates + if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Auto-merge patch & minor + if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Flag major updates for review + if: steps.metadata.outputs.update-type == 'version-update:semver-major' + run: gh pr edit "$PR_URL" --add-label "major-update" --add-label "needs-review" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}