name: ci

inputs:
  nodeversion:
    required: true

runs:
  using: "composite"
  steps:
      - name: Use Node.js ${{ inputs.nodeversion }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ inputs.nodeversion }}

      - name: Install Ruby
        uses: ruby/setup-ruby@v1
        with:
          # The Ruby Version needs to be pinned because fontcustom is no longer maintained
          ruby-version: '2.7.8'
          bundler-cache: true

      - name: Install Fontcustom
        run: |
          sudo apt-get install zlib1g-dev fontforge -y
          git clone https://github.com/bramstein/sfnt2woff-zopfli.git sfnt2woff-zopfli && cd sfnt2woff-zopfli && make && mv sfnt2woff-zopfli /usr/local/bin/sfnt2woff
          git clone --recursive https://github.com/google/woff2.git && cd woff2 && make clean all && sudo mv woff2_compress /usr/local/bin/ && sudo mv woff2_decompress /usr/local/bin/
          gem install fontcustom -v 1.3.8
        shell: bash

      # Need python2 for npm clean install
      - name: Set up Python 2.7.18
        run: |
          sudo apt-get update
          sudo apt install python2-minimal
          export PATH=$PATH:/usr/bin/python2
        shell: bash

      - name: Npm Clean Install
        run: npm ci
        shell: bash

      - name: Build
        run: npm run build
        shell: bash
