name: Seahorse Build

on:
  schedule:
    - cron: '0 0 1 * *'

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      
      - name: Install dependencies
        run: |
          sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
          export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
          solana -V
          rustc -V
          sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev libssl-dev
          cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
          avm install 0.27.0
          avm use 0.27.0
          cargo install seahorse-lang
          declare -a StringArray=(
              "basics/counter/seahorse"
              "basics/hello-solana/seahorse"
              "basics/transfer-sol/seahorse"
              "oracles/pyth/seahorse"
          )
          for val in "${StringArray[@]}"; do
             echo "Building $val..."
             cd $val
             seahorse build
             cd - > /dev/null
          done
        shell: bash
