name: CD Font Build

on:
  push:
    paths:
    - '**.svg'
    - 'font-build.json'
    - 'meta.json'

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Rename Font
      run: sed -i 's/"Material Design Icons"/"Material Design Icons Desktop"/g' font-build.json
    - name: Build font
      run: npx @mdi/font-build --mode svg
    - name: Clone MaterialDesign-Font and Copy
      run: |
        git clone https://${{ secrets.GIT_USER }}:${{ secrets.GIT_TOKEN }}@github.com/Templarian/MaterialDesign-Font
        cp -rf dist/fonts/materialdesignicons-webfont.ttf MaterialDesign-Font/MaterialDesignIconsDesktop.ttf
        cp -rf dist/index.html MaterialDesign-Font/cheatsheet.html
        cd MaterialDesign-Font
        git config --global user.email "${{ secrets.GIT_EMAIL }}"
        git config --global user.name "${{ secrets.GIT_NAME }}"
        git add MaterialDesignIconsDesktop.ttf
        git add cheatsheet.html
        git commit -m "Sync"
        git push