-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
117 lines (103 loc) · 3.88 KB
/
google-fonts.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
name: Google Fonts
on:
push:
branches:
- debug-google-fonts
schedule:
- cron: "0 0 * * 0" # weekly
workflow_dispatch:
jobs:
google-fonts:
name: ${{ matrix.mode }}
if: github.repository == 'Homebrew/homebrew-cask'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- noun: addition
mode: add
- noun: update
mode: update
- noun: deletion
mode: delete
steps:
- name: Checkout homebrew/cask-fonts
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Checkout google/fonts
uses: actions/checkout@v4
with:
repository: google/fonts
path: vendor/google-fonts
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Python packages
run: pip3 install gftools html2text jinja2 protobuf
- name: Configure Git user
id: git-user-config
uses: Homebrew/actions/git-user-config@master
with:
username: ${{ (github.event_name == 'workflow_dispatch' && github.actor) || 'BrewTestBot' }}
- name: Set up commit signing
uses: Homebrew/actions/setup-commit-signing@master
with:
signing_key: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY }}
- name: Import Google Fonts
run: ./developer/bin/import_google_fonts vendor/google-fonts ${{ matrix.mode }}
- name: Check for changes
id: changes-check
run: |
git add Casks
if git diff --cached --stat --exit-code
then
echo "changes=false" >> "$GITHUB_ENV"
else
echo "changes=true" >> "$GITHUB_ENV"
fi
- name: Checkout branch
if: env.changes == 'true'
run: git checkout -b "auto-${{ matrix.mode }}-google-fonts"
- name: Create commits
if: env.changes == 'true'
run: |
# Silence lint error to avoid excessive double quote escaping.
# shellcheck disable=SC2016
git diff --cached --name-only -z | xargs -0 -I {} sh -c '
MESSAGE="$(basename "{}" .rb)"
git commit "{}" --message="$MESSAGE: $MODE" --message="$COMMIT_BODY"'
env:
COMMIT_BODY: >
This commit was created automatically by the
[\`google-fonts\`](https://github.com/Homebrew/homebrew-cask/blob/master/.github/workflows/google-fonts.yml)
workflow.
GIT_COMMITTER_NAME: ${{ steps.git-user-config.outputs.name }}
GIT_COMMITTER_EMAIL: ${{ steps.git-user-config.outputs.email }}
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
MODE: ${{ matrix.mode }}
- name: Push commits
if: env.changes == 'true'
uses: Homebrew/actions/git-try-push@master
with:
token: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }}
branch: "auto-${{ matrix.mode }}-google-fonts"
GIT_COMMITTER_NAME: ${{ steps.git-user-config.outputs.name }}
GIT_COMMITTER_EMAIL: ${{ steps.git-user-config.outputs.email }}
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
- name: Create pull request with updated files
if: env.changes == 'true'
env:
GH_TOKEN: ${{ secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN }}
PR_BODY: >
This pull request was created automatically by the
[`google-fonts`](https://github.com/Homebrew/homebrew-cask/blob/master/.github/workflows/google-fonts.yml)
workflow.
run: |
gh pr create \
--base master \
--body "$PR_BODY" \
--head "auto-${{ matrix.mode }}-google-fonts" \
--title "${{matrix.mode}} Google Fonts"