Skip to content
Latchkey

PR Target Check workflow (SharpAI/DeepCamera)

The PR Target Check workflow from SharpAI/DeepCamera, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, 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: SharpAI/DeepCamera.github/workflows/pr-target-check.ymlLicense MITView source

What it does

This is the PR Target Check workflow from the SharpAI/DeepCamera 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: PR Target Check

on:
  pull_request:
    types: [opened, reopened, edited, synchronize]

jobs:
  check-target:
    runs-on: ubuntu-latest
    steps:
      - name: Enforce branch strategy
        run: |
          BASE="${{ github.event.pull_request.base.ref }}"
          HEAD="${{ github.event.pull_request.head.ref }}"

          echo "PR: $HEAD → $BASE"

          if [ "$BASE" = "master" ] && [ "$HEAD" != "develop" ]; then
            echo "❌ Only the 'develop' branch can open PRs to 'master'."
            echo "   Please target 'develop' instead."
            exit 1
          fi

          if [ "$BASE" = "develop" ] && [ "$HEAD" = "master" ]; then
            echo "❌ Do not merge 'master' back into 'develop'."
            exit 1
          fi

          echo "✅ PR target is valid: $HEAD → $BASE"

The same workflow, on Latchkey

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

name: PR Target Check
 
on:
  pull_request:
    types: [opened, reopened, edited, synchronize]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  check-target:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Enforce branch strategy
        run: |
          BASE="${{ github.event.pull_request.base.ref }}"
          HEAD="${{ github.event.pull_request.head.ref }}"
 
          echo "PR: $HEAD → $BASE"
 
          if [ "$BASE" = "master" ] && [ "$HEAD" != "develop" ]; then
            echo "❌ Only the 'develop' branch can open PRs to 'master'."
            echo "   Please target 'develop' instead."
            exit 1
          fi
 
          if [ "$BASE" = "develop" ] && [ "$HEAD" = "master" ]; then
            echo "❌ Do not merge 'master' back into 'develop'."
            exit 1
          fi
 
          echo "✅ PR target is valid: $HEAD → $BASE"
 

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.