Skip to content

Dispatch rebottle

Dispatch rebottle #107

name: Dispatch rebottle
on:
workflow_dispatch:
inputs:
formula:
description: Formula name
required: true
timeout:
description: "Build timeout (in minutes, default: 60 minutes)"
default: "90"
required: true
issue:
description: Issue number, where comment on failure would be posted
required: false
upload:
description: Whether to upload built bottles or not
required: false
fail-fast:
description: "Whether to fail immediately on a single macOS version failure (default: true)"
default: "true"
required: false
env:
HOMEBREW_DEVELOPER: 1
HOMEBREW_GITHUB_ACTIONS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_FROM_API: 1
jobs:
bottle:
strategy:
matrix:
include:
- runner: macos-13
- runner: macos-12
- runner: macos-14-arm64
- runner: macos-13-arm64
- runner: macos-12-arm64
- runner: ubuntu-latest
container:
image: homebrew/ubuntu22.04:latest
options: --user=linuxbrew
workdir: /github/home
timeout: 4320
fail-fast: ${{fromJson(github.event.inputs.fail-fast)}}
runs-on: ${{ matrix.runner }}
container: ${{matrix.container}}
timeout-minutes: ${{fromJson(github.event.inputs.timeout)}}
defaults:
run:
working-directory: ${{matrix.workdir || github.workspace}}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
steps:
- name: ${{github.event.inputs.formula}}
id: print_details
run: |
echo sender=${{github.event.sender.login}}
echo formula=${{github.event.inputs.formula}}
echo timeout=${{github.event.inputs.timeout}}
echo issue=${{github.event.inputs.issue}}
echo upload=${{github.event.inputs.upload}}
- name: Set environment variables
if: runner.os == 'macOS'
run: echo 'PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' >> $GITHUB_ENV
- name: Prepare Container
if: runner.os == 'Linux'
run: |
sudo chmod 777 ${{matrix.workdir || github.workspace}}
brew update
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- run: brew test-bot --only-cleanup-before
- run: brew test-bot --only-setup
- name: Run brew test-bot --only-formulae --only-json-tab --skip-online-checks --skip-dependents
env:
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
mkdir bottles
cd bottles
brew test-bot --only-json-tab --only-formulae --skip-dependents --skip-online-checks --root-url="https://ghcr.io/v2/${{ github.repository_owner }}/php" ${{ github.repository_owner }}/php/${{github.event.inputs.formula}}
- name: Failures summary for brew test-bot --only-formulae
if: always()
run: |
touch bottles/steps_output.txt
cat bottles/steps_output.txt
rm bottles/steps_output.txt
- name: Output brew bottle result
if: always()
run: |
cat bottles/bottle_output.txt
rm bottles/bottle_output.txt
- name: Upload logs
if: failure()
uses: actions/upload-artifact@v3
with:
if-no-files-found: ignore
name: logs
path: ${{matrix.workdir || github.workspace}}/bottles/logs
- name: Delete logs and home
if: always()
run: |
rm -rvf bottles/logs
rm -rvf bottles/home
rm -rvf bottles/failed
- name: Count bottles
id: bottles
if: always()
run: |
cd bottles
count=$(ls *.json | wc -l | xargs echo -n)
echo "$count bottles"
echo "count=$count" | sudo tee -a "$GITHUB_OUTPUT"
- name: Upload bottles to GitHub Actions
if: always() && steps.bottles.outputs.count > 0
uses: actions/upload-artifact@v3
with:
name: bottles
path: ${{matrix.workdir || github.workspace}}/bottles
- name: Post cleanup
if: always()
run: |
brew test-bot --only-cleanup-after
rm -rvf bottles
- name: Post comment on failure
if: ${{!success() && github.event.inputs.issue > 0}}
uses: Homebrew/actions/post-comment@master
with:
token: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}}
issue: ${{github.event.inputs.issue}}
body: ":x: @${{github.actor}} bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}})."
bot_body: ":x: Bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}})."
bot: BrewTestBot
upload:
runs-on: ubuntu-22.04
needs: bottle
if: github.event.inputs.upload
env:
HOMEBREW_FORCE_HOMEBREW_ON_LINUX: 1
steps:
- name: ${{github.event.inputs.formula}}
id: print_details
run: |
echo sender=${{github.event.sender.login}}
echo formula=${{github.event.inputs.formula}}
echo issue=${{github.event.inputs.issue}}
echo upload=${{github.event.inputs.upload}}
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
test-bot: false
- name: Download bottles from GitHub Actions
uses: actions/download-artifact@v3
with:
name: bottles
path: ~/bottles/
- name: Setup git
run: |
git config --local user.email [email protected]
git config --local user.name BrewTestBot
- name: Upload bottles to GitHub Packages
env:
HOMEBREW_GITHUB_PACKAGES_USER: ${{ github.repository_owner }}
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
cd ~/bottles
brew pr-upload --verbose --root-url="https://ghcr.io/v2/${{ github.repository_owner }}/php"
- name: Push commits
uses: Homebrew/actions/git-try-push@master
with:
token: ${{secrets.GITHUB_TOKEN}}
- name: Post comment on failure
if: ${{!success() && github.event.inputs.issue > 0}}
uses: Homebrew/actions/post-comment@master
with:
token: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}}
issue: ${{github.event.inputs.issue}}
body: ':x: @${{github.actor}} bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}}).'
bot_body: ':x: Bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}}).'
bot: BrewTestBot