name: Build pages and publish

on:
  push

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.2.2
          bundler-cache: true
      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: '14'
      - run: npm install
      - name: Build site
        uses: limjh16/jekyll-action-ts@v2
        with:
          enable_cache: true
      - run: bundle exec htmlproofer ./_site --no-check-external-hash --no-enforce-https --ignore-urls "/localhost/,/www.linkedin.com/,digitalocean.com,/cloud.digitalocean.com/,/dnschecker.org/,/npmjs.com/,polar.sh,/reddit.com/r/inventree/,/twitter.com/inventreedb/,/github.com/,/developer.digikey.com/,/patreon.com/,/partkeepr.org/,/download.dymo.com/,brother.com.au,/marketplace.digitalocean.com"
        name: Check links
      - name: Deploy
        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main'}}
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_branch: 'gh-pages'
          publish_dir: ./_site
