diff --git a/.github/workflows/create-replacement-pr.yml b/.github/workflows/create-replacement-pr.yml index 0e22f1c75e52e..b793df960bea3 100644 --- a/.github/workflows/create-replacement-pr.yml +++ b/.github/workflows/create-replacement-pr.yml @@ -19,7 +19,7 @@ on: upload: description: > Upload bottles built from original pull request? (default: false) - Warning: This destroys status check information! + Warning: This destroys status check information when used with autosquash! type: boolean required: false default: false @@ -72,23 +72,6 @@ jobs: with: test-bot: false - - name: Configure Git user - id: git-user-config - uses: Homebrew/actions/git-user-config@master - with: - username: BrewTestBot - - - name: Checkout replacement PR branch - working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} - run: | - if git ls-remote --exit-code --heads origin "$REPLACEMENT_BRANCH" - then - echo "::error ::Branch $REPLACEMENT_BRANCH already exists!" - exit 1 - fi - - git checkout -b "$REPLACEMENT_BRANCH" origin/master - - name: Get reviewers id: reviewers env: @@ -107,6 +90,37 @@ jobs: echo "reviewers=$reviewers" >> "$GITHUB_OUTPUT" echo "approved=$approved" >> "$GITHUB_OUTPUT" + - name: Check approval if needed + if: inputs.upload && !fromJson(steps.reviewers.outputs.approved) + run: | + echo "::error ::Refusing to upload bottles because PR #$PR is not approved!" + exit 1 + + - name: Configure Git user + id: git-user-config + uses: Homebrew/actions/git-user-config@master + with: + username: BrewTestBot + + - name: Checkout PR branch + if: ${{ !inputs.autosquash }} + working-directory: ${{steps.set-up-homebrew.outputs.repository-path}} + env: + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: gh pr checkout "$PR" + + - name: Checkout replacement PR branch + working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }} + env: + START_POINT: ${{ inputs.autosquash && 'origin/master' || 'HEAD' }} + run: | + if git ls-remote --exit-code --heads origin "$REPLACEMENT_BRANCH" + then + echo "::error ::Branch $REPLACEMENT_BRANCH already exists!" + exit 1 + fi + git checkout -b "$REPLACEMENT_BRANCH" "$START_POINT" + - name: Dismiss approvals if: fromJson(steps.reviewers.outputs.approved) uses: Homebrew/actions/dismiss-approvals@master @@ -137,7 +151,7 @@ jobs: --workflows=tests.yml \ --committer="$BREWTESTBOT_NAME_EMAIL" \ --root-url="https://ghcr.io/v2/homebrew/core" \ - "${{ inputs.autosquash && '--autosquash' || '--clean' }}" \ + ${{ inputs.autosquash && '--autosquash' || '--clean --no-cherry-pick' }} \ ${{ inputs.upload && '' || '--no-upload' }} \ ${{ inputs.warn_on_upload_failure && '--warn-on-upload-failure' || '' }} \ ${{ inputs.message && '--message="$MESSAGE"' || '' }} \ diff --git a/.github/workflows/publish-commit-bottles.yml b/.github/workflows/publish-commit-bottles.yml index 7cc308ea29271..b555045760ff0 100644 --- a/.github/workflows/publish-commit-bottles.yml +++ b/.github/workflows/publish-commit-bottles.yml @@ -191,7 +191,7 @@ jobs: --ref "$GITHUB_REF_NAME" \ --field pull_request="$PR" \ --field autosquash="$AUTOSQUASH" \ - --field upload=false \ + --field upload='${{ !inputs.autosquash }}' \ --field warn_on_upload_failure=false \ --field message="$MESSAGE"