Skip to content
Latchkey

rails-bot: Label PRs workflow (rails/rails)

The rails-bot: Label PRs workflow from rails/rails, explained and optimized by Latchkey.

A

CI health: A - excellent

Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: rails/rails.github/workflows/labeler.ymlLicense MITView source

What it does

This is the rails-bot: Label PRs workflow from the rails/rails repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

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

The workflow

workflow (.yml)
name: "rails-bot: Label PRs"
on:
  # This event runs in the context of the base of the pull request, rather than
  # in the context of the merge commit, as the pull_request event does. This
  # prevents execution of unsafe code from the head of the pull request that
  # could alter your repository or steal any secrets you use in your workflow.
  # This event allows your workflow to do things like label or comment on pull
  # requests from forks. Avoid using this event if you need to build or run
  # code from the pull request.
  #
  # https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target
  pull_request_target:

jobs:
  labeler:
    permissions:
      contents: read
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/labeler@v6
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}

The same workflow, on Latchkey

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

name: "rails-bot: Label PRs"
on:
  # This event runs in the context of the base of the pull request, rather than
  # in the context of the merge commit, as the pull_request event does. This
  # prevents execution of unsafe code from the head of the pull request that
  # could alter your repository or steal any secrets you use in your workflow.
  # This event allows your workflow to do things like label or comment on pull
  # requests from forks. Avoid using this event if you need to build or run
  # code from the pull request.
  #
  # https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target
  pull_request_target:
 
jobs:
  labeler:
    timeout-minutes: 30
    permissions:
      contents: read
      pull-requests: write
    runs-on: latchkey-small
    steps:
      - uses: actions/labeler@v6
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
 
 

What changed

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