diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..e9cc8e8 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,39 @@ +name: CodeQL + +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: + schedule: + - cron: '27 3 * * 2' + +permissions: + contents: read + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + runs-on: ubuntu-latest + permissions: + contents: read + security-events: write + strategy: + fail-fast: false + matrix: + language: [actions, javascript-typescript, rust] + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Initialize CodeQL + uses: github/codeql-action/init@793b778da9c9275a0f276522b27cb5fc14bba279 # v4 + with: + languages: ${{ matrix.language }} + build-mode: none + - name: Analyze + uses: github/codeql-action/analyze@793b778da9c9275a0f276522b27cb5fc14bba279 # v4 + with: + category: /language:${{ matrix.language }} diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..d4a0f40 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,52 @@ +name: Dependabot auto-merge + +on: + pull_request: + branches: [main] + types: [opened, reopened, synchronize] + pull_request_target: + branches: [main] + types: [opened, reopened, synchronize] + +permissions: {} + +jobs: + enable: + name: Dependabot auto-merge admission + if: >- + github.repository == 'structured-world/omloom' && + github.event.pull_request.user.login == 'dependabot[bot]' && + github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + # This privileged workflow never checks out or executes pull-request code. + # Metadata must come from signed Dependabot commits in this repository. + - name: Verify Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2 + # pull_request records the required check on the PR head. The trusted + # target run repeats admission before it can authorize the native merge. + - name: Verify every commit + shell: bash + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + # The metadata action validates the first commit. Reject any later + # unsigned or human-authored addition before enabling native auto-merge. + gh api --paginate --slurp "repos/$GH_REPO/pulls/$PR_NUMBER/commits" | + jq -e '([.[][]] | length) > 0 and all(.[][]; .author.login == "dependabot[bot]" and .commit.verification.verified == true)' > /dev/null + - name: Enable auto-merge for GitHub Actions updates + if: >- + github.event_name == 'pull_request_target' && + steps.metadata.outputs.package-ecosystem == 'github_actions' + env: + GH_TOKEN: ${{ github.token }} + PR_URL: ${{ github.event.pull_request.html_url }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + gh pr merge "$PR_URL" --auto --squash --match-head-commit "$PR_HEAD_SHA"