name: Deploy Site

on:
  push:
    branches:
    - master
    paths:
    - '_site/**'

jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
      AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
      S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
      CLOUDFRONT_ID: ${{ secrets.CLOUDFRONT_ID }}
      PUSHOVER_TOKEN: ${{ secrets.PUSHOVER_TOKEN }}
      PUSHOVER_USER: ${{ secrets.PUSHOVER_USER }}
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-java@v1
      with:
        java-version: '8'
    - name: Install babashka
      run: |
         curl -s https://raw.githubusercontent.com/borkdude/babashka/master/install -o install-bb
         chmod +x install-bb
         sudo ./install-bb
         rm install-bb
    - name: Install Clojure
      run: |
        curl -O https://download.clojure.org/install/linux-install-1.10.1.536.sh
        chmod +x linux-install-1.10.1.536.sh
        sudo ./linux-install-1.10.1.536.sh
    - run: clojure --report stderr deploy.clj | bb -I --stream pushover-notify.clj
