Homebrew Bump Formula #485
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: Homebrew Bump Formula | |
on: | |
schedule: | |
- cron: '23 17 * * *' | |
workflow_dispatch: | |
inputs: | |
reason: | |
description: Brief reason for running this workflow manually | |
required: false | |
default: not specified by user | |
type: string | |
jobs: | |
homebrew: | |
name: Bump Homebrew formula | |
runs-on: macos-latest | |
steps: | |
- id: latest_release | |
uses: pozetroninc/[email protected] | |
with: | |
repository: ${{ github.repository }} | |
excludes: prerelease, draft | |
token: ${{ secrets.FLYIO_FLYCTL_BOT_GITHUB_TOKEN }} | |
- run: 'echo "Latest release: ${{ steps.latest_release.outputs.release }}"' | |
- uses: actions/checkout@v4 | |
- id: version_compare | |
run: | | |
set -exo pipefail | |
brew update | |
cur_brew_version=$(brew info flyctl --json --quiet | jq -r '.[0].versions.stable') | |
version_comp=$(./scripts/semver compare ${{ steps.latest_release.outputs.release }} ${cur_brew_version}) | |
if [ "${version_comp}" = "1" ] ; then | |
echo "VERSION_STATUS=update_needed" >> "$GITHUB_OUTPUT" | |
else | |
echo "VERSION_STATUS=no_change" >> "$GITHUB_OUTPUT" | |
fi | |
- run: 'echo "VERSION_STATUS=${{ steps.version_compare.outputs.VERSION_STATUS }}"' | |
- uses: dawidd6/action-homebrew-bump-formula@v3 | |
if: ${{ steps.version_compare.outputs.VERSION_STATUS == 'update_needed' }} | |
with: | |
token: ${{ secrets.FLYIO_FLYCTL_BOT_GITHUB_TOKEN }} | |
formula: flyctl | |
tag: ${{ steps.latest_release.outputs.release }} | |
force: false | |
- name: Check for slack secret | |
if: ${{ failure() && steps.version_compare.outputs.VERSION_STATUS == 'update_needed' }} | |
env: | |
SLACK_WEBHOOK_EXISTS: ${{ secrets.HOMEBREW_SLACK_WEBHOOK_URL != '' }} | |
run: if [ ${{ env.SLACK_WEBHOOK_EXISTS }} != "true" ] ; then echo "No webhook url :-(" ; fi | |
- name: Post failure to slack | |
if: ${{ failure() && steps.version_compare.outputs.VERSION_STATUS == 'update_needed' }} | |
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.HOMEBREW_SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
with: | |
payload: | | |
{ | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": ":fire: flyctl bump homebrew formula failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
} | |
] | |
} |