245 lines (217 loc) Β· 7.5 KB
/
scheduled.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
name: Scheduled regeneration
on:
push:
paths:
- .github/workflows/scheduled.yml
schedule:
# Once every hour
- cron: "0 * * * *"
workflow_dispatch:
concurrency:
group: scheduled-${{ github.ref }}
cancel-in-progress: true
jobs:
generate-cask:
if: startsWith( github.repository, 'Homebrew/' )
name: Generate homebrew/cask data, pages and API
runs-on: macos-latest
steps:
- name: Check out repository
uses: actions/checkout@main
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Update data for homebrew/cask
run: |
brew update-reset $(brew --repository homebrew/cask)
/usr/bin/rake cask
- name: Archive data
run: tar czvf data-cask.tar.gz _data/cask/ api/cask/ cask/
- uses: actions/upload-artifact@v3
with:
name: data-cask
path: data-cask.tar.gz
retention-days: 1
generate-core:
if: startsWith( github.repository, 'Homebrew/' )
name: Generate homebrew/core data, pages and API
runs-on: macos-latest
steps:
- name: Check out repository
uses: actions/checkout@main
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Update data for homebrew/core
run: /usr/bin/rake formulae
- name: Archive data
run: tar czvf data-core.tar.gz _data/formula/ _data/formula_canonical.json api/formula/ formula/
- uses: actions/upload-artifact@v3
with:
name: data-core
path: data-core.tar.gz
retention-days: 1
generate-analytics:
if: startsWith( github.repository, 'Homebrew/' )
name: Generate analytics data
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@main
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.6"
- name: Set up analytics
env:
ANALYTICS_JSON_KEY: ${{ secrets.HOMEBREW_FORMULAE_BREW_SH_ANALYTICS_JSON_KEY }}
run: echo "$ANALYTICS_JSON_KEY" > ~/.homebrew_analytics.json
- name: Update analytics data
run: rake all_analytics
- name: Archive data
run: tar czvf data-analytics.tar.gz _data/analytics _data/analytics-linux api/analytics api/analytics-linux
- uses: actions/upload-artifact@v3
with:
name: data-analytics
path: data-analytics.tar.gz
retention-days: 1
generate-samples:
if: startsWith( github.repository, 'Homebrew/' )
name: Generate API samples
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@main
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.6"
- name: Update data for api samples
run: rake api_samples
- uses: actions/upload-artifact@v3
with:
name: api-samples
path: _includes/api-samples/
retention-days: 1
build:
needs: [generate-cask, generate-core, generate-analytics, generate-samples]
runs-on: ubuntu-22.04
steps:
- name: Set up Git repository
uses: actions/checkout@master
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.6"
bundler-cache: true
- uses: actions/download-artifact@v3
- name: Move artifacts into place
run: |
tar xvf data-analytics/data-analytics.tar.gz
tar xvf data-cask/data-cask.tar.gz
tar xvf data-core/data-core.tar.gz
mv -v api-samples _includes/api-samples
- name: Build site
run: bundle exec rake build
- name: Validate build
run: ./script/validate-build.rb
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
deploy:
needs: build
if: ${{ github.ref_name == 'master' }}
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
outputs:
deploy_url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
deploy-issue:
name: Open/close deploy issues
needs:
[
generate-cask,
generate-core,
generate-analytics,
generate-samples,
build,
deploy,
]
if: ${{ always() && github.ref_name == 'master' }}
env:
GH_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }}
REPO: ${{ github.repository }}
runs-on: ubuntu-latest
steps:
- name: Find existing deploy failure issue
run: |
EXISTING_ISSUE=$(gh issue list --repo "$REPO" --author BrewTestBot --label 'deploy failure' | awk '{print $1}')
echo "EXISTING_ISSUE=$EXISTING_ISSUE" >> $GITHUB_ENV
echo "WORKFLOW_URL=https://github.com/Homebrew/formulae.brew.sh/actions/runs/$RUN_ID" >> $GITHUB_ENV
env:
RUN_ID: ${{ github.run_id }}
- name: Report deploy failure
if: ${{ contains(needs.*.result, 'failure') }}
run: |
ISSUE_TITLE="formulae.brew.sh deployment failed!"
ISSUE_BODY="The most recent [formulae.brew.sh deployment failed]($WORKFLOW_URL)."
if [ -n "$EXISTING_ISSUE" ]; then
gh issue edit "$EXISTING_ISSUE" --repo "$REPO" --body "$(echo -e "$ISSUE_BODY")"
else
gh issue create --repo "$REPO" --title "$ISSUE_TITLE" --label "deploy failure" --body "$(echo -e "$ISSUE_BODY")"
fi
- name: Report deploy success
if: ${{ needs.deploy.result == 'success' }}
run: |
COMMENT_BODY="The most recent [formulae.brew.sh deployment succeeded]($WORKFLOW_URL). Closing issue."
if [ -n "$EXISTING_ISSUE" ]; then
gh issue comment "$EXISTING_ISSUE" --repo "$REPO" --body "$(echo -e "$COMMENT_BODY")"
gh issue close "$EXISTING_ISSUE" --repo "$REPO"
fi
# This is run on a schedule by Algolia too so we don't care about failures.
algolia_recrawl:
needs: deploy
name: Algolia Recrawl
runs-on: ubuntu-latest
steps:
- name: Algolia crawler creation and recrawl
uses: algolia/algoliasearch-crawler-github-actions@v1
continue-on-error: true
id: crawler_push
with:
crawler-name: Homebrew Search (https://*brew.sh)
site-url: ${{ needs.deploy.outputs.deploy_url }}
crawler-user-id: ${{ secrets.CRAWLER_USER_ID }}
crawler-api-key: ${{ secrets.CRAWLER_API_KEY }}
algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }}
algolia-api-key: ${{ secrets.ALGOLIA_API_KEY }}
- name: Unconditional success step
run: true