Skip to content
Latchkey

Merge main into dev workflow (nunchaku-ai/ComfyUI-nunchaku)

The Merge main into dev workflow from nunchaku-ai/ComfyUI-nunchaku, 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: nunchaku-ai/ComfyUI-nunchaku.github/workflows/merge-main-into-dev.yamlLicense Apache-2.0View source

What it does

This is the Merge main into dev workflow from the nunchaku-ai/ComfyUI-nunchaku 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: Merge main into dev
on:
  push:
    branches:
      - main
permissions:
  contents: write
jobs:
  merge-main-into-dev:
    runs-on: ubuntu-latest
    if: github.repository == 'nunchaku-ai/ComfyUI-nunchaku'
    steps:
      - name: Checkout the repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: ${{ secrets.GH_TOKEN }}
      - name: Check if main and dev are already in sync
        id: check_sync
        run: |
          git fetch origin main dev
          MAIN_SHA=$(git rev-parse origin/main)
          DEV_SHA=$(git rev-parse origin/dev)
          echo "main sha: $MAIN_SHA"
          echo "dev sha: $DEV_SHA"
          if [ "$MAIN_SHA" = "$DEV_SHA" ]; then
            echo "Branches are in sync. Skipping merge."
            echo "skip_merge=true" >> "$GITHUB_OUTPUT"
          else
            echo "Branches differ. Proceeding with merge."
            echo "skip_merge=false" >> "$GITHUB_OUTPUT"
          fi
      - name: Merge main into dev
        id: last_commit
        if: steps.check_sync.outputs.skip_merge == 'false'
        run: |
          # Get author name and email from last commit on main
          AUTHOR_NAME=$(git log origin/main -1 --pretty=format:'%an')
          AUTHOR_EMAIL=$(git log origin/main -1 --pretty=format:'%ae')
          LAST_MSG=$(git log origin/main -1 --pretty=%s)

          echo "Author: $AUTHOR_NAME <$AUTHOR_EMAIL>"
          echo "Last commit message: $LAST_MSG"

          # Set Git user to last author
          git config --global user.name "$AUTHOR_NAME"
          git config --global user.email "$AUTHOR_EMAIL"

          git checkout dev
          git merge origin/main -m "[Auto Merge] $LAST_MSG"
          git push origin dev

The same workflow, on Latchkey

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

name: Merge main into dev
on:
  push:
    branches:
      - main
permissions:
  contents: write
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  merge-main-into-dev:
    timeout-minutes: 30
    runs-on: latchkey-small
    if: github.repository == 'nunchaku-ai/ComfyUI-nunchaku'
    steps:
      - name: Checkout the repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: ${{ secrets.GH_TOKEN }}
      - name: Check if main and dev are already in sync
        id: check_sync
        run: |
          git fetch origin main dev
          MAIN_SHA=$(git rev-parse origin/main)
          DEV_SHA=$(git rev-parse origin/dev)
          echo "main sha: $MAIN_SHA"
          echo "dev sha: $DEV_SHA"
          if [ "$MAIN_SHA" = "$DEV_SHA" ]; then
            echo "Branches are in sync. Skipping merge."
            echo "skip_merge=true" >> "$GITHUB_OUTPUT"
          else
            echo "Branches differ. Proceeding with merge."
            echo "skip_merge=false" >> "$GITHUB_OUTPUT"
          fi
      - name: Merge main into dev
        id: last_commit
        if: steps.check_sync.outputs.skip_merge == 'false'
        run: |
          # Get author name and email from last commit on main
          AUTHOR_NAME=$(git log origin/main -1 --pretty=format:'%an')
          AUTHOR_EMAIL=$(git log origin/main -1 --pretty=format:'%ae')
          LAST_MSG=$(git log origin/main -1 --pretty=%s)
 
          echo "Author: $AUTHOR_NAME <$AUTHOR_EMAIL>"
          echo "Last commit message: $LAST_MSG"
 
          # Set Git user to last author
          git config --global user.name "$AUTHOR_NAME"
          git config --global user.email "$AUTHOR_EMAIL"
 
          git checkout dev
          git merge origin/main -m "[Auto Merge] $LAST_MSG"
          git push origin dev
 

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