when:
  - event: manual
    branch: main
  - event: push
    branch: main
    path: '.woodpecker/pmd.yaml'

steps:
  - name: pmd
    environment:
      PROJECT_NAME: pmd
      PROJECT_PRETTY_NAME: pmd
      FEED_REVISION: 1

      CODEBERG_GIT_USERNAME:
        from_secret: codeberg_git_username
      CODEBERG_GIT_PASSWORD:
        from_secret: codeberg_git_password
    image: codeberg.org/mark22k/ci:latest
    pull: true
    commands:
      - GIT_BRANCH="gh-pages"
      - GIT_URL="https://github.com/pmd/pmd.git"
      - . ./scripts/environment.sh
      - . ./scripts/install_dashing.sh
      - . ./scripts/download_from_git.sh
      - . ./scripts/prepare_docs_directory.sh
      - cd "$BASE_DIRECTORY/pmd"
      - PROJECT_VERSION="pmd-$(git rev-parse --short HEAD)"
      - cp -r ./* "$DOCS_DIRECTORY"
      - |
          cat << EOF > "$DOCS_DIRECTORY/dashing.json"
          {
              "name": "pmd",
              "package": "pmd",
              "index": "index.html",
              "selectors": {
                  "dt code": "Option",
                  "h2": "Section",
                  "h1": "Guide"
              },
              "allowJS": false
          }
          EOF
      - cd "$FEED_DIRECTORY"
      - . ./scripts/build_dashing.sh
      - . ./scripts/create_docs_tarball.sh
      - . ./scripts/create_feed.sh
      - . ./scripts/publish.sh
