Skip to content
Latchkey

Dependabot auto-merge workflow (prometheus/prometheus)

The Dependabot auto-merge workflow from prometheus/prometheus, explained and optimized by Latchkey.

A

CI health: A - excellent

The optimized version below adds job timeouts.

Source: prometheus/prometheus.github/workflows/automerge-dependabot.ymlLicense Apache-2.0View source

What it does

This is the Dependabot auto-merge workflow from the prometheus/prometheus repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
---
name: Dependabot auto-merge
on: pull_request

concurrency:
  group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  dependabot:
    permissions:
      contents: write
      pull-requests: write
    runs-on: ubuntu-latest
    if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.repository_owner == 'prometheus' }}
    steps:
    - name: Dependabot metadata
      id: metadata
      uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
      with:
        github-token: "${{ secrets.GITHUB_TOKEN }}"
    - name: Enable auto-merge for Dependabot PRs
      if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
      run: gh pr merge --auto --merge "$PR_URL"
      env:
        PR_URL: ${{github.event.pull_request.html_url}}
        GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

---name: Dependabot auto-mergeon: pull_request concurrency:  group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}  cancel-in-progress: true permissions:  contents: read jobs:  dependabot:    timeout-minutes: 30    permissions:      contents: write      pull-requests: write    runs-on: latchkey-small    if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.repository_owner == 'prometheus' }}    steps:    - name: Dependabot metadata      id: metadata      uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0      with:        github-token: "${{ secrets.GITHUB_TOKEN }}"    - name: Enable auto-merge for Dependabot PRs      if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'}}      run: gh pr merge --auto --merge "$PR_URL"      env:        PR_URL: ${{github.event.pull_request.html_url}}        GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 

What changed

  • Run on Latchkey managed runners with one line (runs-on), which apply the fixes below automatically and self-heal transient failures. This example uses latchkey-small; pick the runner size that fits the job.
  • Add a job timeout so a hung step cannot burn hours of runner time.

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow

dependabot/fetch-metadata

Frequently asked questions

What does the Dependabot auto-merge workflow (prometheus/prometheus) workflow do?
This is the Dependabot auto-merge workflow from the prometheus/prometheus repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
What CI health grade does this workflow get?
This Automation and other workflow grades A. Paste your own workflow into the Latchkey grader to see its grade and the exact fixes.
How can I improve this Automation and other workflow?
Apply job timeouts. Latchkey applies these automatically on managed runners when you point runs-on at Latchkey.

References