name: Docs
on:
  push:
    branches: [main]
  schedule:
    - cron: '0 0 * * 0'
jobs:
  docs:
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, '[skip ci]')"
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v2
        with:
          repository: neovim/neovim-ruby
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: head
      - name: Install libfuse
        run: sudo apt install libfuse2
      - name: Bundle install
        run: |
          bundle config set path vendor/bundle
          bundle install --jobs 3 --retry 3
      - name: Install Neovim
        run: bundle exec rake ci:download_nvim
      - name: Generate docs
        env:
          NVIM_EXECUTABLE: "_nvim/bin/nvim"
        run: bundle exec rake docs:generate
      - name: Open pull request
        uses: peter-evans/create-pull-request@v3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: "[skip ci] Update generated docs"
          author: Docs Workflow <noreply@github.com>
          title: "Update generated docs"
