From 4947b510df6ad7d516c9093b47cfa82717e4868b Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Fri, 17 May 2024 15:54:02 +0100 Subject: [PATCH] setup-homebrew: handle stable on stable Docker images --- .github/workflows/setup-homebrew.yml | 13 +++++++++++++ setup-homebrew/main.sh | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/setup-homebrew.yml b/.github/workflows/setup-homebrew.yml index 377f41da..80c96582 100644 --- a/.github/workflows/setup-homebrew.yml +++ b/.github/workflows/setup-homebrew.yml @@ -16,20 +16,31 @@ jobs: include: - os: macos-latest key: macos + stable: false - os: ubuntu-20.04 key: ubuntu-20 + stable: false - os: ubuntu-22.04 key: ubuntu-22 + stable: false - os: ubuntu-22.04 key: docker-root + stable: false container: image: ghcr.io/homebrew/ubuntu22.04:master options: --user=root - os: ubuntu-22.04 key: docker-linuxbrew + stable: false container: image: ghcr.io/homebrew/ubuntu22.04:master options: --user=linuxbrew + - os: ubuntu-22.04 + key: docker-linuxbrew-stable + stable: true + container: + image: ghcr.io/homebrew/ubuntu22.04:latest + options: --user=linuxbrew runs-on: ${{ matrix.os }} container: ${{ matrix.container }} steps: @@ -60,6 +71,8 @@ jobs: - name: Set up Homebrew id: set-up-homebrew uses: ./setup-homebrew/ + with: + stable: ${{ matrix.stable }} - name: Cache Homebrew Bundler RubyGems id: cache diff --git a/setup-homebrew/main.sh b/setup-homebrew/main.sh index 84feacb3..804c53a7 100755 --- a/setup-homebrew/main.sh +++ b/setup-homebrew/main.sh @@ -144,7 +144,12 @@ if [[ "$GITHUB_REPOSITORY" =~ ^.+/brew$ ]]; then echo "repository-path=$HOMEBREW_REPOSITORY" >>"$GITHUB_OUTPUT" else git_retry -C "$HOMEBREW_REPOSITORY" fetch --force --tags origin - git -C "$HOMEBREW_REPOSITORY" checkout --force -B master origin/HEAD + git_retry -C "$HOMEBREW_REPOSITORY" remote set-head origin --auto + if [[ "${STABLE}" == "true" && "$(git symbolic-ref --short HEAD 2>/dev/null)" != "master" ]]; then + git -C "$HOMEBREW_REPOSITORY" branch --force -B master origin/HEAD + else + git -C "$HOMEBREW_REPOSITORY" checkout --force -B master origin/HEAD + fi if [[ -n "${HOMEBREW_TAP_REPOSITORY-}" ]]; then echo "repository-path=$HOMEBREW_TAP_REPOSITORY" >>"$GITHUB_OUTPUT"