-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tidy] Pull material icons on a monthly basis (#973)
- Loading branch information
1 parent
87e7653
commit 41865a6
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Update Material Icons | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 1 * *" # Runs at midnight on the 1st of every month | ||
|
||
defaults: | ||
run: | ||
working-directory: vizro-core | ||
|
||
env: | ||
PYTHON_VERSION: "3.12" | ||
|
||
jobs: | ||
check-update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout main branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
- name: Install Hatch | ||
run: pip install hatch | ||
- name: Update Material font | ||
run: | | ||
hatch run update-icons | ||
- name: Check for changes | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "Vizro Team" | ||
git diff --exit-code || echo "has_changes=true" >> $GITHUB_ENV | ||
update-icons: | ||
runs-on: ubuntu-latest | ||
needs: [check-update] | ||
if: | | ||
env.has_changes == 'true' | ||
steps: | ||
- name: Delete old branch if exists | ||
run: | | ||
git push origin --delete bot/update-material-icons || true | ||
- name: Create and push changes | ||
run: | | ||
git checkout -b bot/update-material-icons | ||
hatch run changelog:add | ||
git add -A | ||
git commit -m "Update Material Icons" | ||
git push --set-upstream origin bot/update-material-icons | ||
- name: Install GitHub CLI | ||
run: sudo apt-get install -y gh | ||
- name: Create Pull Request | ||
run: | | ||
gh pr create -B main -H bot/update-material-icons --title "[Bot] Update Material Icons" --body "Automated update of Material Icons" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
48 changes: 48 additions & 0 deletions
48
vizro-core/changelog.d/20250130_110817_huong_li_nguyen_update_icons_script.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!-- | ||
A new scriv changelog fragment. | ||
Uncomment the section that is right (remove the HTML comment wrapper). | ||
--> | ||
|
||
<!-- | ||
### Highlights ✨ | ||
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Removed | ||
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Added | ||
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Changed | ||
- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Deprecated | ||
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Fixed | ||
- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Security | ||
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Script to update the Google Material Design Icons font in the static folder.""" | ||
|
||
import logging | ||
from pathlib import Path | ||
|
||
import requests | ||
|
||
FONT_URL = "https://github.com/google/material-design-icons/raw/refs/heads/master/variablefont/MaterialSymbolsOutlined%5BFILL,GRAD,opsz,wght%5D.woff2" | ||
LOCAL_PATH = Path(__file__).parent.parent / "src/vizro/static/css/fonts/material-symbols-outlined.woff2" | ||
STATUS_OK = 200 | ||
TIMEOUT = 10 # seconds | ||
|
||
logging.basicConfig(level=logging.INFO, format="%(message)s") | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def download_font(url, path): | ||
"""Downloads the Material Design Icons font from Google Fonts and saves it to the local static folder.""" | ||
try: | ||
response = requests.get(url, timeout=TIMEOUT) | ||
if response.status_code == STATUS_OK: | ||
path.write_bytes(response.content) | ||
logger.info(f"✍️ Material font downloaded and saved to {path}") | ||
else: | ||
logger.error(f"❌ Failed to download Material font. Status code: {response.status_code}") | ||
except requests.RequestException as e: | ||
logger.error(f"❌ Failed to download Material font due to an unexpected error: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
download_font(FONT_URL, LOCAL_PATH) |