name: Eleventy Build

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v2 # Check out the repository

      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: '18'

      - name: Cache npm
        uses: actions/cache@v3
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}

      - run: npm ci # Install dependencies

      - run: npm run build # Build the site

      # Copy the dist/ folder into _site/dist
      - run: cp -r dist/ _site/dist

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }} # GitHub token automatically generated
          publish_dir: './_site' # Directory to deploy
          exclude_assets: '.github,**/.gitignore'
          cname: zinc.style
