Skip to content
Latchkey

backport workflow (spegel-org/spegel)

The backport workflow from spegel-org/spegel, 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: spegel-org/spegel.github/workflows/backport.yamlLicense MITView source

What it does

This is the backport workflow from the spegel-org/spegel 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: backport
on:
  pull_request_target:
    types: [closed, labeled]
permissions:
  contents: read
defaults:
  run:
    shell: bash
jobs:
  pr:
    runs-on: ubuntu-latest
    if: github.event.pull_request.state == 'closed' && github.event.pull_request.merged && (github.event_name != 'labeled' || startsWith('backport:', github.event.label.name))
    steps:
      - name: Generate bot token
        uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
        id: bot
        with:
          client-id: ${{ secrets.PORTABOTTY_CLIENT_ID }}
          private-key: ${{ secrets.PORTABOTTY_PRIVATE_KEY }}
          repositories: ${{ github.event.repository.name }}
          permission-contents: write
          permission-pull-requests: write
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
        with:
          token: ${{ steps.bot.outputs.token }}
          ref: ${{ github.event.pull_request.head.sha }}
      - name: Create backport PR
        uses: korthout/backport-action@66065406958f46e82238fd59546f5a99e69e22aa # v4.5.2
        with:
          github_token: ${{ steps.bot.outputs.token }}
          label_pattern: '^backport:([^ ]+)$'
          copy_labels_pattern: '^changelog\/\S+'
          pull_title: '[${target_branch}] ${pull_title}'
          pull_description: |-
            Automated backport to `${target_branch}`, triggered by a label in #${pull_number}.
          experimental: >
            {
              "conflict_resolution": "draft_commit_conflicts"
            }

The same workflow, on Latchkey

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

name: backport
on:
  pull_request_target:
    types: [closed, labeled]
permissions:
  contents: read
defaults:
  run:
    shell: bash
jobs:
  pr:
    timeout-minutes: 30
    runs-on: latchkey-small
    if: github.event.pull_request.state == 'closed' && github.event.pull_request.merged && (github.event_name != 'labeled' || startsWith('backport:', github.event.label.name))
    steps:
      - name: Generate bot token
        uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
        id: bot
        with:
          client-id: ${{ secrets.PORTABOTTY_CLIENT_ID }}
          private-key: ${{ secrets.PORTABOTTY_PRIVATE_KEY }}
          repositories: ${{ github.event.repository.name }}
          permission-contents: write
          permission-pull-requests: write
      - name: Checkout
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
        with:
          token: ${{ steps.bot.outputs.token }}
          ref: ${{ github.event.pull_request.head.sha }}
      - name: Create backport PR
        uses: korthout/backport-action@66065406958f46e82238fd59546f5a99e69e22aa # v4.5.2
        with:
          github_token: ${{ steps.bot.outputs.token }}
          label_pattern: '^backport:([^ ]+)$'
          copy_labels_pattern: '^changelog\/\S+'
          pull_title: '[${target_branch}] ${pull_title}'
          pull_description: |-
            Automated backport to `${target_branch}`, triggered by a label in #${pull_number}.
          experimental: >
            {
              "conflict_resolution": "draft_commit_conflicts"
            }
 

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