Run CircleCI from label workflow (okteto/okteto)
The Run CircleCI from label workflow from okteto/okteto, explained and optimized by Latchkey.
CI health: C - fair
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Run CircleCI from label workflow from the okteto/okteto 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
name: Run CircleCI from label
on:
pull_request:
types:
- opened
- labeled
- unlabeled
- synchronize
jobs:
run-e2e-windows:
if: |
contains(github.event.pull_request.labels.*.name, 'run-e2e-windows') &&
!contains(github.event.pull_request.labels.*.name, 'run-e2e') &&
(github.event.action != 'labeled' && github.event.action != 'unlabeled' || github.event.label.name == 'run-e2e-windows')
uses: ./.github/workflows/trigger-circleci-e2e.yml
with:
gha_meta: "run-e2e-windows"
branch: ${{ github.head_ref }}
pr_number: ${{ github.event.pull_request.number }}
secrets:
CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
run-e2e-unix:
if: |
contains(github.event.pull_request.labels.*.name, 'run-e2e-unix') &&
!contains(github.event.pull_request.labels.*.name, 'run-e2e') &&
(github.event.action != 'labeled' && github.event.action != 'unlabeled' || github.event.label.name == 'run-e2e-unix')
uses: ./.github/workflows/trigger-circleci-e2e.yml
with:
gha_meta: "run-e2e-unix"
branch: ${{ github.head_ref }}
pr_number: ${{ github.event.pull_request.number }}
secrets:
CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
run-e2e:
if: |
contains(github.event.pull_request.labels.*.name, 'run-e2e') &&
(github.event.action != 'labeled' && github.event.action != 'unlabeled' || github.event.label.name == 'run-e2e')
uses: ./.github/workflows/trigger-circleci-e2e.yml
with:
gha_meta: "run-e2e"
branch: ${{ github.head_ref }}
pr_number: ${{ github.event.pull_request.number }}
secrets:
CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
cancel-e2e-windows:
if: github.event.action == 'unlabeled' && github.event.label.name == 'run-e2e-windows'
uses: ./.github/workflows/trigger-circleci-e2e.yml
with:
gha_meta: "run-e2e-windows"
branch: ${{ github.head_ref }}
pr_number: ${{ github.event.pull_request.number }}
cancel_only: true
secrets:
CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
cancel-e2e-unix:
if: github.event.action == 'unlabeled' && github.event.label.name == 'run-e2e-unix'
uses: ./.github/workflows/trigger-circleci-e2e.yml
with:
gha_meta: "run-e2e-unix"
branch: ${{ github.head_ref }}
pr_number: ${{ github.event.pull_request.number }}
cancel_only: true
secrets:
CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
cancel-e2e:
if: github.event.action == 'unlabeled' && github.event.label.name == 'run-e2e'
uses: ./.github/workflows/trigger-circleci-e2e.yml
with:
gha_meta: "run-e2e"
branch: ${{ github.head_ref }}
pr_number: ${{ github.event.pull_request.number }}
cancel_only: true
secrets:
CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Run CircleCI from label on: pull_request: types: - opened - labeled - unlabeled - synchronize concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: run-e2e-windows: timeout-minutes: 30 if: | contains(github.event.pull_request.labels.*.name, 'run-e2e-windows') && !contains(github.event.pull_request.labels.*.name, 'run-e2e') && (github.event.action != 'labeled' && github.event.action != 'unlabeled' || github.event.label.name == 'run-e2e-windows') uses: ./.github/workflows/trigger-circleci-e2e.yml with: gha_meta: "run-e2e-windows" branch: ${{ github.head_ref }} pr_number: ${{ github.event.pull_request.number }} secrets: CCI_TOKEN: ${{ secrets.CCI_TOKEN }} run-e2e-unix: timeout-minutes: 30 if: | contains(github.event.pull_request.labels.*.name, 'run-e2e-unix') && !contains(github.event.pull_request.labels.*.name, 'run-e2e') && (github.event.action != 'labeled' && github.event.action != 'unlabeled' || github.event.label.name == 'run-e2e-unix') uses: ./.github/workflows/trigger-circleci-e2e.yml with: gha_meta: "run-e2e-unix" branch: ${{ github.head_ref }} pr_number: ${{ github.event.pull_request.number }} secrets: CCI_TOKEN: ${{ secrets.CCI_TOKEN }} run-e2e: timeout-minutes: 30 if: | contains(github.event.pull_request.labels.*.name, 'run-e2e') && (github.event.action != 'labeled' && github.event.action != 'unlabeled' || github.event.label.name == 'run-e2e') uses: ./.github/workflows/trigger-circleci-e2e.yml with: gha_meta: "run-e2e" branch: ${{ github.head_ref }} pr_number: ${{ github.event.pull_request.number }} secrets: CCI_TOKEN: ${{ secrets.CCI_TOKEN }} cancel-e2e-windows: timeout-minutes: 30 if: github.event.action == 'unlabeled' && github.event.label.name == 'run-e2e-windows' uses: ./.github/workflows/trigger-circleci-e2e.yml with: gha_meta: "run-e2e-windows" branch: ${{ github.head_ref }} pr_number: ${{ github.event.pull_request.number }} cancel_only: true secrets: CCI_TOKEN: ${{ secrets.CCI_TOKEN }} cancel-e2e-unix: timeout-minutes: 30 if: github.event.action == 'unlabeled' && github.event.label.name == 'run-e2e-unix' uses: ./.github/workflows/trigger-circleci-e2e.yml with: gha_meta: "run-e2e-unix" branch: ${{ github.head_ref }} pr_number: ${{ github.event.pull_request.number }} cancel_only: true secrets: CCI_TOKEN: ${{ secrets.CCI_TOKEN }} cancel-e2e: timeout-minutes: 30 if: github.event.action == 'unlabeled' && github.event.label.name == 'run-e2e' uses: ./.github/workflows/trigger-circleci-e2e.yml with: gha_meta: "run-e2e" branch: ${{ github.head_ref }} pr_number: ${{ github.event.pull_request.number }} cancel_only: true secrets: CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- End-to-end and browser tests
This workflow runs 6 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.