webhook #4331
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 Release | |
on: | |
repository_dispatch: | |
types: | |
- webhook | |
jobs: | |
release-cli: | |
name: Release CLI | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
- uses: tibdex/github-app-token@v1 | |
id: generate-token | |
with: | |
app_id: ${{ secrets.PR_APP_ID }} | |
private_key: ${{ secrets.PR_APP_PRIVATE_KEY }} | |
- name: Enable corepack | |
id: enable-corepack | |
run: corepack enable | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-static-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: ${{ runner.os }}-yarn- | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20.x | |
- name: Install dependencies | |
run: yarn | |
- name: Update CLI | |
run: yarn update-fragment-cli-version --stage ${{ github.event.client_payload.stage }} --cli-version ${{ github.event.client_payload.version }} | |
env: | |
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Brew Install Fragment CLI Beta on ${{ matrix.os }} | |
if: ${{ github.event.client_payload.stage == 'dev' }} | |
run: | | |
brew install --build-from-source Formula/fragment-cli-beta.rb | |
echo "Fragment CLI installed" | |
fragment --version | |
fragment init -f ${{ github.run_id }}-dev.jsonc | |
- name: Brew Install Fragment CLI Prod on ${{ matrix.os }} | |
if: ${{ github.event.client_payload.stage == 'prod' }} | |
run: | | |
brew install --build-from-source Formula/fragment-cli.rb | |
echo "Fragment CLI installed" | |
fragment --version | |
fragment init -f ${{ github.run_id }}-prod.jsonc | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v3 | |
# This is just so it doesn't try to push twice. The alternative is to create another workflow which will | |
# depend on the brew install, but then we have to locally update the homebrew formulae again, which seems kind of wasteful. | |
if: ${{ matrix.os == 'ubuntu-latest'}} | |
with: | |
token: ${{ steps.generate-token.outputs.token }} | |
commit-message: Update FRAGMENT CLI in stage ${{ github.event.client_payload.stage }} to version ${{ github.event.client_payload.version }} | |
title: Update FRAGMENT CLI ${{ github.event.client_payload.stage }} ${{ github.event.client_payload.version }} | |
delete-branch: true | |
branch: update-cli/${{ github.event.client_payload.stage }} | |
base: "main" | |
body: > | |
This PR is auto-generated by a github action. | |
labels: automated pr, ${{ github.event.client_payload.stage }}, automerge | |
- name: Post failed release slack message | |
uses: rtCamp/action-slack-notify@v2 | |
if: ${{ failure() }} | |
env: | |
SLACK_CHANNEL: deploy-failures | |
SLACK_COLOR: #FF0000 | |
SLACK_ICON: https://pbs.twimg.com/profile_images/1038548670768181249/L5Y34Ygo_400x400.jpg | |
SLACK_MESSAGE: "Please investigate the failure." | |
SLACK_TITLE: CLI release failure in ${{ github.event.client_payload.stage }} (version ${{ github.event.client_payload.version }}) | |
SLACK_USERNAME: Fragment CLI Bot | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_DEPLOY_FAILURE_CHANNEL }} |