mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2025-02-23 15:34:20 +01:00
83 lines
3.7 KiB
YAML
83 lines
3.7 KiB
YAML
name: "[Icon] Icon update approved"
|
|
on:
|
|
issues:
|
|
types: [labeled]
|
|
|
|
jobs:
|
|
update-icon:
|
|
runs-on: ubuntu-latest
|
|
# This condition ensures the job only runs when the 'approved' label is updated and the issue title starts with 'feat(icons): update '
|
|
if: |
|
|
contains(github.event.issue.labels.*.name, 'approved') &&
|
|
startsWith(github.event.issue.title, 'feat(icons): update ')
|
|
env:
|
|
ICON_TYPE: ${{ contains(github.event.issue.labels.*.name, 'normal-icon') && 'normal' || 'monochrome' }}
|
|
steps:
|
|
- name: Obtain token
|
|
id: obtainToken
|
|
uses: tibdex/github-app-token@v2
|
|
with:
|
|
private_key: ${{ secrets.DASHBOARD_ICONS_MANAGER_APP_PRIVATE_KEY }}
|
|
app_id: ${{ vars.DASHBOARD_ICONS_MANAGER_APP_ID }}
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
env:
|
|
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
|
- name: Set Up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: "3.11"
|
|
- name: Install Dependencies
|
|
run: |
|
|
pip install cairosvg pillow requests
|
|
sudo apt-get update
|
|
sudo apt-get install -y zopfli webp
|
|
- name: Parse issue form
|
|
id: parse_issue_form
|
|
run: echo "ISSUE_FORM=$(python scripts/parse_issue_form.py)" >> "$GITHUB_OUTPUT"
|
|
env:
|
|
INPUT_ISSUE_BODY: ${{ github.event.issue.body }}
|
|
- name: Update metadata file
|
|
run: python scripts/generate_metadata_file.py ${{ env.ICON_TYPE }} update
|
|
env:
|
|
INPUT_ISSUE_FORM: ${{ steps.parse_issue_form.outputs.ISSUE_FORM }}
|
|
INPUT_ISSUE_AUTHOR_ID: ${{ github.event.issue.user.id }}
|
|
INPUT_ISSUE_AUTHOR_LOGIN: ${{ github.event.issue.user.login }}
|
|
- name: Generate icons
|
|
run: python scripts/generate_icons.py ${{ env.ICON_TYPE }} update
|
|
env:
|
|
INPUT_ISSUE_FORM: ${{ steps.parse_issue_form.outputs.ISSUE_FORM }}
|
|
- name: Generate File Tree
|
|
run: python scripts/generate_file_tree.py svg png webp
|
|
- name: Generate ICONS.md
|
|
run: python scripts/generate_icons_page.py
|
|
- name: Extract icon name
|
|
id: extract_icon_name
|
|
run: echo "ICON_NAME=$(python scripts/print_icon_name.py ${{ env.ICON_TYPE }} update)" >> "$GITHUB_OUTPUT"
|
|
env:
|
|
INPUT_ISSUE_FORM: ${{ steps.parse_issue_form.outputs.ISSUE_FORM }}
|
|
- name: Compress icons
|
|
run: |
|
|
echo "Compressing PNGs..."
|
|
find png/ -iname "${{ steps.extract_icon_name.outputs.ICON_NAME }}*.png" -print0 | xargs -0 -P 4 -I{} zopflipng -y {} {}
|
|
echo "Compressing WEBPs..."
|
|
find webp/ -iname "${{ steps.extract_icon_name.outputs.ICON_NAME }}*.webp" -print0 | xargs -0 -P 4 -I{} bash -c 'cwebp -quiet -lossless "$1" -o "$1"' _ {}
|
|
- name: Commit changes
|
|
run: |
|
|
git config --global user.email "193821040+dashboard-icons-manager[bot]@users.noreply.github.com"
|
|
git config --global user.name "Dashboard Icons Manager"
|
|
git add .
|
|
git commit -m "feat(icons): update ${{ steps.extract_icon_name.outputs.ICON_NAME }}"
|
|
|
|
- name: Create Pull Request
|
|
uses: peter-evans/create-pull-request@v7
|
|
with:
|
|
token: ${{ steps.obtainToken.outputs.token }}
|
|
branch: icons/update-${{steps.extract_icon_name.outputs.ICON_NAME}}
|
|
base: main
|
|
title: "feat(icons): update ${{steps.extract_icon_name.outputs.ICON_NAME}}"
|
|
delete-branch: true
|
|
body: |
|
|
This PR updates the icon ${{steps.extract_icon_name.outputs.ICON_NAME}} like requested in #${{github.event.issue.number}} to the project.
|
|
Closes #${{github.event.issue.number}}
|