Publish and commit bottles #1881
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish and commit bottles | |
on: | |
workflow_dispatch: | |
inputs: | |
pull_request: | |
description: Pull request number | |
required: true | |
large_runner: | |
description: "Run the upload job on a large runner? (default: false)" | |
type: boolean | |
required: false | |
default: false | |
autosquash: | |
description: "Squash pull request commits according to Homebrew style? (default: false)" | |
type: boolean | |
required: false | |
default: false | |
warn_on_upload_failure: | |
description: "Pass `--warn-on-upload-failure` to `brew pr-pull`? (default: false)" | |
type: boolean | |
required: false | |
default: false | |
message: | |
description: "Message to include when autosquashing revision bumps, deletions, and rebuilds (requires autosquash)" | |
required: false | |
env: | |
HOMEBREW_DEVELOPER: 1 | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
HOMEBREW_NO_INSTALL_FROM_API: 1 | |
GH_REPO: ${{github.repository}} | |
GH_DEBUG: 1 | |
GH_NO_UPDATE_NOTIFIER: 1 | |
GH_PROMPT_DISABLED: 1 | |
jobs: | |
upload: | |
runs-on: ubuntu-22.04 | |
container: | |
image: ghcr.io/homebrew/ubuntu22.04:master | |
steps: | |
- name: Post comment once started | |
uses: Homebrew/actions/post-comment@master | |
with: | |
token: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} | |
issue: ${{github.event.inputs.pull_request}} | |
body: ':beers: @BrewTestBot has [triggered a merge](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}}).' | |
bot_body: ':robot: A scheduled task has [triggered a merge](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}}).' | |
bot: BrewTestBot | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
with: | |
test-bot: false | |
- name: Setup git | |
run: | | |
git config --global user.email [email protected] | |
git config --global user.name BrewTestBot | |
- name: Pull bottles | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
HOMEBREW_GITHUB_PACKAGES_USER: ${{ github.repository_owner }} | |
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: | | |
sudo sed -i 's/Closes ##{pr}/[skip ci]/g' "$(brew --repository)"/Library/Homebrew/dev-cmd/pr-pull.rb | |
# Don't quote arguments that might be empty; this causes errors. | |
brew pr-pull \ | |
--debug \ | |
--workflows=build.yml \ | |
--tap=${{ github.repository_owner }}/php \ | |
--root-url="https://ghcr.io/v2/${{ github.repository_owner }}/php" \ | |
'${{inputs.autosquash && '--autosquash' || '--clean'}}' \ | |
${{inputs.warn_on_upload_failure && '--warn-on-upload-failure' || ''}} \ | |
${{inputs.message && format('--message="{0}"', inputs.message) || ''}} \ | |
'${{github.event.inputs.pull_request}}' | |
- name: Merge PR branch | |
working-directory: ${{steps.set-up-homebrew.outputs.repository-path}} | |
run: bash .github/scripts/retry.sh 5 5 gh pr merge ${{github.event.inputs.pull_request}} --auto --delete-branch --rebase | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
- name: Push commits | |
uses: Homebrew/actions/git-try-push@master | |
with: | |
directory: ${{steps.set-up-homebrew.outputs.repository-path}} | |
token: ${{secrets.GITHUB_TOKEN}} | |
- name: Post comment on failure | |
if: ${{!success()}} | |
uses: Homebrew/actions/post-comment@master | |
with: | |
token: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} | |
issue: ${{github.event.inputs.pull_request}} | |
body: ':warning: @${{github.actor}} bottle publish [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}}).' | |
bot_body: ':warning: Bottle publish [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}}).' | |
bot: BrewTestBot | |
- name: Dismiss approvals on failure | |
if: ${{!success()}} | |
uses: Homebrew/actions/dismiss-approvals@master | |
with: | |
token: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} | |
pr: ${{github.event.inputs.pull_request}} | |
message: 'bottle publish failed' |