From 82ad03fe2893fa1ea1f093291f82a16e0b594880 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Fri, 19 Apr 2024 11:05:39 +0800 Subject: [PATCH] dev-cmd/tap-new: various improvements 1. Update `actions/cache` to `v4`. 2. Unset GitHub Packages tokens if unused. 3. Quote shell variables. --- Library/Homebrew/dev-cmd/tap-new.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/dev-cmd/tap-new.rb b/Library/Homebrew/dev-cmd/tap-new.rb index 7fc1009236..c77d943292 100644 --- a/Library/Homebrew/dev-cmd/tap-new.rb +++ b/Library/Homebrew/dev-cmd/tap-new.rb @@ -63,11 +63,13 @@ module Homebrew actions_main = <<~YAML name: brew test-bot + on: push: branches: - #{branch} pull_request: + jobs: test-bot: strategy: @@ -80,8 +82,7 @@ module Homebrew uses: Homebrew/actions/setup-homebrew@master - name: Cache Homebrew Bundler RubyGems - id: cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.set-up-homebrew.outputs.gems-path }} key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} @@ -93,7 +94,7 @@ module Homebrew - run: brew test-bot --only-tap-syntax - - run: brew test-bot --only-formulae#{" --root-url=#{root_url}" if root_url} + - run: brew test-bot --only-formulae#{" --root-url='#{root_url}'" if root_url} if: github.event_name == 'pull_request' - name: Upload bottles as artifact @@ -106,10 +107,12 @@ module Homebrew actions_publish = <<~YAML name: brew pr-pull + on: pull_request_target: types: - labeled + jobs: pr-pull: if: contains(github.event.pull_request.labels.*.name, '#{label}') @@ -128,10 +131,10 @@ module Homebrew - name: Pull bottles env: HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} - HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{ github.token }} - HOMEBREW_GITHUB_PACKAGES_USER: ${{ github.repository_owner }} + HOMEBREW_GITHUB_PACKAGES_TOKEN: #{args.github_packages? ? "${{ github.token }}" : "null"} + HOMEBREW_GITHUB_PACKAGES_USER: #{args.github_packages? ? "${{ github.repository_owner }}" : "null"} PULL_REQUEST: ${{ github.event.pull_request.number }} - run: brew pr-pull --debug --tap=$GITHUB_REPOSITORY $PULL_REQUEST + run: brew pr-pull --debug --tap="$GITHUB_REPOSITORY" "$PULL_REQUEST" - name: Push commits uses: Homebrew/actions/git-try-push@master @@ -143,7 +146,7 @@ module Homebrew if: github.event.pull_request.head.repo.fork == false env: BRANCH: ${{ github.event.pull_request.head.ref }} - run: git push --delete origin $BRANCH + run: git push --delete origin "$BRANCH" YAML (tap.path/".github/workflows").mkpath