feat(icons): add vitalPBX #383
This file contains hidden or 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
name: "[Icon] Icon addition approved" | |
on: | |
issues: | |
types: [labeled] | |
jobs: | |
add-icon: | |
runs-on: ubuntu-latest | |
# This condition ensures the job only runs when the 'approved' label is added and the issue title starts with 'feat(icons): add ' | |
if: | | |
contains(github.event.issue.labels.*.name, 'approved') && | |
startsWith(github.event.issue.title, 'feat(icons): add ') | |
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: Create metadata file | |
run: python scripts/generate_metadata_file.py ${{ env.ICON_TYPE }} addition | |
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 }} addition | |
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 full metadata file | |
run: python scripts/generate_metadata.py | |
- name: Extract icon name | |
id: extract_icon_name | |
run: echo "ICON_NAME=$(python scripts/print_icon_name.py ${{ env.ICON_TYPE }} addition)" >> "$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): add ${{ 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/add-${{steps.extract_icon_name.outputs.ICON_NAME}} | |
base: main | |
title: "feat(icons): add ${{steps.extract_icon_name.outputs.ICON_NAME}}" | |
delete-branch: true | |
body: | | |
This PR adds the icon ${{steps.extract_icon_name.outputs.ICON_NAME}} added in #${{github.event.issue.number}} to the project. | |
Closes #${{github.event.issue.number}} |