forked from Homebrew/brew
-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (101 loc) · 3.74 KB
/
sorbet.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Update Sorbet files
on:
pull_request:
paths:
- Library/Homebrew/dev-cmd/typecheck.rb
- Library/Homebrew/sorbet/**
- "!Library/Homebrew/sorbet/rbi/**"
push:
paths:
- .github/workflows/sorbet.yml
branches-ignore:
- master
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
permissions:
contents: read
defaults:
run:
shell: bash -xeuo pipefail {0}
jobs:
tapioca:
if: github.repository == 'Homebrew/brew'
runs-on: macos-14
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
core: false
cask: false
test-bot: false
- name: Configure Git user
if: github.event_name != 'pull_request'
uses: Homebrew/actions/git-user-config@master
with:
username: BrewTestBot
- name: Set up commit signing
if: github.event_name != 'pull_request'
uses: Homebrew/actions/setup-commit-signing@master
with:
signing_key: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY }}
- name: Update RBI files
id: update
working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}
run: |
if [[ "${GITHUB_EVENT_NAME}" != "pull_request" ]]
then
git fetch origin
BRANCH="sorbet-files-update"
echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT"
if git ls-remote --exit-code --heads origin "${BRANCH}"
then
git checkout "${BRANCH}"
git checkout "Library/Homebrew/sorbet"
else
git checkout --no-track -B "${BRANCH}" origin/master
fi
fi
brew typecheck --update --suggest-typed
- name: Commit changes
id: commit
if: github.event_name != 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }}
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}
run: |
if ! git diff --stat --exit-code "Library/Homebrew/sorbet"
then
git add "Library/Homebrew/sorbet"
git commit -m "sorbet: Update RBI files." \
-m "Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow."
if ! git diff --stat --exit-code "Library/Homebrew"
then
git add "Library/Homebrew/"
git commit -m "sorbet: Autobump sigils via Spoom" \
-m "Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow."
fi
echo "committed=true" >> "$GITHUB_OUTPUT"
PULL_REQUEST_STATE="$(gh pr view --json=state | jq -r ".state")"
if [[ "${PULL_REQUEST_STATE}" != "OPEN" ]]
then
echo "pull_request=true" >> "$GITHUB_OUTPUT"
fi
fi
- name: Push commits
if: steps.commit.outputs.committed == 'true'
uses: Homebrew/actions/git-try-push@master
with:
token: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }}
directory: ${{ steps.set-up-homebrew.outputs.repository-path }}
branch: ${{ steps.update.outputs.branch }}
force: true
origin_branch: "master"
- name: Open a pull request
if: steps.commit.outputs.pull_request == 'true'
run: gh pr create --fill
env:
GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }}
working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}