sorbet.yml 2.2 KB
Newer Older
Markus Reiter's avatar
Markus Reiter 已提交
1
name: Update Sorbet files
2

3
4
5
on:
  push:
    paths:
6
      - .github/workflows/sorbet.yml
7
8
    branches-ignore:
      - master
9
  schedule:
10
    - cron: "0 0 * * *"
11
12
  workflow_dispatch:

13
14
15
jobs:
  tapioca:
    if: github.repository == 'Homebrew/brew'
16
    runs-on: macos-latest
17
18
19
20
21
22
23
24
25
26
    steps:
      - name: Set up Homebrew
        id: set-up-homebrew
        uses: Homebrew/actions/setup-homebrew@master

      - name: Configure Git user
        uses: Homebrew/actions/git-user-config@master
        with:
          username: BrewTestBot

27
28
29
30
31
      - name: Set up commit signing
        uses: Homebrew/actions/setup-commit-signing@master
        with:
          signing_key: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY }}

32
      - name: Update RBI files
33
        id: update
34
        env:
nandahkrishna's avatar
nandahkrishna 已提交
35
          HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
36
        run: |
37
38
          git fetch origin

39
          BRANCH="sorbet-files-update"
40
41
42
43
44
45
46
47
48
          echo "::set-output name=branch::${BRANCH}"

          if git ls-remote --exit-code --heads origin "$BRANCH"; then
            git checkout "$BRANCH"
            git reset origin/master
          else
            git checkout -B "$BRANCH" origin/master
            BRANCH_EXISTS="1"
          fi
49

50
          if brew typecheck --update --fail-if-not-changed; then
Mike McQuaid's avatar
Mike McQuaid 已提交
51
            git add "$GITHUB_WORKSPACE/Library/Homebrew/sorbet"
Markus Reiter's avatar
Markus Reiter 已提交
52
53
            git commit -m "sorbet: Update RBI files." \
                       -m "Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow."
Mike McQuaid's avatar
Mike McQuaid 已提交
54
            echo "::set-output name=committed::true"
55
56
57
            if [ -n "$BRANCH_EXISTS" ]; then
              echo "::set-output name=pull_request::true"
            fi
58
59
60
61
62
63
64
          fi

      - name: Push commits
        if: steps.update.outputs.committed == 'true'
        uses: Homebrew/actions/git-try-push@master
        with:
          token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
65
          branch: ${{ steps.update.outputs.branch }}
Mike McQuaid's avatar
Mike McQuaid 已提交
66
          force: true
67
68

      - name: Open a pull request
69
        if: steps.update.outputs.pull_request == 'true'
70
        run: hub pull-request --no-edit
71
72
        env:
          GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}