Skip to content

google

google #1136

Workflow file for this run

name: google
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
import:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- name: Install otfinfo
run: |
sudo apt-get update
sudo apt-get install lcdf-typetools
- name: Cache Google fonts repo
uses: actions/cache@v4
with:
path: "~/.fontist/google/fonts"
key: google-fonts-repo-${{ github.run_number }}
restore-keys: |
google-fonts-repo-
- name: Clone or update Google fonts repo
run: |
mkdir -p ~/.fontist/google
if [ -d ~/.fontist/google/fonts/.git ]; then
cd ~/.fontist/google/fonts
git fetch origin
git reset --hard origin/main
else
rm -rf ~/.fontist/google/fonts
git clone --depth 1 https://github.com/google/fonts ~/.fontist/google/fonts
fi
- name: Setup fontist config
run: bundle exec fontist config set read_timeout 60
- name: Import new fonts
id: import
continue-on-error: true
run: |
bundle exec fontist import google \
--source-path ~/.fontist/google/fonts \
--output-path Formulas/google \
--schema-version 5 \
-v 2>&1 | tee import-output.log
echo "exit_code=${PIPESTATUS[0]}" >> $GITHUB_OUTPUT
- name: Upload import logs
if: always()
uses: actions/upload-artifact@v4
with:
name: google-import-logs-${{ github.run_id }}
path: import-output.log
retention-days: 7
- name: Check for formula changes
id: check-changes
if: success()
run: |
if [ -n "$(git status --porcelain Formulas/google)" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "### 📝 Formula Changes Detected" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
git status --short Formulas/google | head -20 >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
else
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "### ℹ️ No formula changes" >> $GITHUB_STEP_SUMMARY
fi
- uses: EndBug/add-and-commit@v7
if: steps.check-changes.outputs.has_changes == 'true'
with:
add: Formulas/google
default_author: github_actions
message: 'chore(formulas): update Google Fonts'
- name: Create issue on repeated failures
if: failure() && github.event_name == 'schedule'
uses: actions/github-script@v7
with:
script: |
const issueTitle = '🔴 Google Fonts Import Failed';
const issueBody = `
## Import Failure Report
The scheduled Google Fonts import failed.
### Details
- **Run ID:** ${{ github.run_id }}
- **Run URL:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
### Action Required
- Review the [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
- Check the uploaded artifacts for detailed error information
`;
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'google-import,automated'
});
const existingIssue = issues.data.find(issue => issue.title === issueTitle);
if (existingIssue) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: `Another failure occurred:\n\n${issueBody}`
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: issueTitle,
body: issueBody,
labels: ['google-import', 'automated', 'bug']
});
}