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

steps:
  - name: bird2
    environment:
      PROJECT_NAME: bird2
      PROJECT_PRETTY_NAME: bird2
      PROJECT_VERSION: 2.16
      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="v$PROJECT_VERSION"
      - GIT_URL="https://gitlab.nic.cz/labs/bird.git"
      - . ./scripts/environment.sh
      - . ./scripts/install_dashing.sh
      - . ./scripts/download_from_git.sh
      - . ./scripts/prepare_docs_directory.sh
      - cd "$BASE_DIRECTORY/bird"
      - autoreconf
      - ./configure
      - make docs
      - cp ./obj/doc/*.html "$DOCS_DIRECTORY"
      - |
          cat << EOF > "$DOCS_DIRECTORY/dashing.json"
          {
              "name": "bird2",
              "package": "bird2",
              "index": "bird.html",
              "selectors": {
                  "dt code": "Option",
                  "h2": "Section",
                  "title": "Guide"
              },
              "allowJS": false
          }
          EOF
      - cd "$FEED_DIRECTORY"
      - . ./scripts/build_dashing.sh
      - . ./scripts/create_docs_tarball.sh
      - . ./scripts/create_feed.sh
      - . ./scripts/publish.sh
