name: Copy contracts

on:
  schedule:
    - cron: "*/5 * * * *"
  workflow_dispatch:

jobs:
  copy-and-push:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          repository: "smartcontractkit/chainlink"
          path: "source"

      - uses: actions/checkout@v2
        with:
          repository: "smartcontractkit/contracts"
          path: "target"
      
      - uses: actions/setup-node@v2
        with:
          node-version: '12'

      - name: Copy Contracts
        run: |
          rm -rf target/contracts/v*/
          cp -r source/evm-contracts/src/* target/contracts/
          npm install -g --force yarn
          cd target && yarn && yarn compile
          
      - uses: EndBug/add-and-commit@v7
        with:
          author_name: Alex Roan
          author_email: alex.roan@hotmail.com
          cwd: target
          push: true
          message: "Copy contracts from smartcontractkit/chainlink"
