Skip to content
Latchkey

Sync Master to Release Branch workflow (quay/quay)

The Sync Master to Release Branch workflow from quay/quay, 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: quay/quay.github/workflows/branch-sync.yamlLicense Apache-2.0View source

What it does

This is the Sync Master to Release Branch workflow from the quay/quay 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: Sync Master to Release Branch

on:
  push:
    branches:
      - master

permissions:
  contents: write

jobs:
  sync_master_to_release:
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repo
        uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          fetch-depth: 0

      - name: Configure Git
        run: |
          git config user.name "GitHub Actions Bot"
          git config user.email "github-actions-bot@users.noreply.github.com"

      - name: Merge master into release
        env:
          BRANCH_NAME: ${{ vars.BRANCH_SYNC_TARGET }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          if [ -z "$BRANCH_NAME" ]; then echo "BRANCH_SYNC_TARGET variable is not set" && exit 1; fi
          echo "Syncing master to $BRANCH_NAME"
          git checkout master
          git pull origin master
          MASTER_COMMIT=$(git rev-parse HEAD)

          git fetch origin $BRANCH_NAME
          git checkout $BRANCH_NAME
          git pull origin $BRANCH_NAME
          RELEASE_COMMIT=$(git rev-parse HEAD)
          echo "Rebasing $BRANCH_NAME ($RELEASE_COMMIT) onto master ($MASTER_COMMIT)"
          git rebase master
          git push origin $BRANCH_NAME

          echo "Merged master ($MASTER_COMMIT) into $BRANCH_NAME ($RELEASE_COMMIT)"

The same workflow, on Latchkey

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

name: Sync Master to Release Branch
 
on:
  push:
    branches:
      - master
 
permissions:
  contents: write
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  sync_master_to_release:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - name: Check out the repo
        uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          fetch-depth: 0
 
      - name: Configure Git
        run: |
          git config user.name "GitHub Actions Bot"
          git config user.email "github-actions-bot@users.noreply.github.com"
 
      - name: Merge master into release
        env:
          BRANCH_NAME: ${{ vars.BRANCH_SYNC_TARGET }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          if [ -z "$BRANCH_NAME" ]; then echo "BRANCH_SYNC_TARGET variable is not set" && exit 1; fi
          echo "Syncing master to $BRANCH_NAME"
          git checkout master
          git pull origin master
          MASTER_COMMIT=$(git rev-parse HEAD)
 
          git fetch origin $BRANCH_NAME
          git checkout $BRANCH_NAME
          git pull origin $BRANCH_NAME
          RELEASE_COMMIT=$(git rev-parse HEAD)
          echo "Rebasing $BRANCH_NAME ($RELEASE_COMMIT) onto master ($MASTER_COMMIT)"
          git rebase master
          git push origin $BRANCH_NAME
 
          echo "Merged master ($MASTER_COMMIT) into $BRANCH_NAME ($RELEASE_COMMIT)"
 

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