# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Also included in R-CMD-check.yaml, this workflow only listens to pushes to branches
# that start with "docs*"
on:
  push:
    branches:
      - "docs*"
      - "cran-*"
  workflow_dispatch:

name: pkgdown

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.sha }}-${{ github.base_ref || '' }}
  cancel-in-progress: true

jobs:
  pkgdown:
    runs-on: ubuntu-latest

    name: "pkgdown"

    # Begin custom: services
    # End custom: services

    steps:
      - uses: actions/checkout@v4

      - uses: ./.github/workflows/rate-limit
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

      - uses: ./.github/workflows/git-identity
        if: github.event_name == 'push'

      - uses: ./.github/workflows/custom/before-install
        if: hashFiles('.github/workflows/custom/before-install/action.yml') != ''

      - uses: ./.github/workflows/install
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          install-r: false
          cache-version: pkgdown-2
          needs: website
          extra-packages: r-lib/pkgdown local::.

      - uses: ./.github/workflows/custom/after-install
        if: hashFiles('.github/workflows/custom/after-install/action.yml') != ''

      - uses: ./.github/workflows/pkgdown-build
        if: github.event_name != 'push'

      - uses: ./.github/workflows/pkgdown-deploy
        if: github.event_name == 'push'
