platform: linux/amd64

labels:
  type: exec

pipeline:
- name: build-docs
  image: bash
  commands:
  - make docker-build docker-build-docs
  - cp _scripts/* _build/html
  - cd _build/html && echo "www.drycc.cc" > CNAME  && echo "drycc.cc" >> CNAME && git init
  secrets:
  - drycc_registry
  when:
    event:
    - tag
    - push

- name: publish-docs
  image: bash
  commands:
  - chown -R root:root _build/html
  - docker run --rm
      -e DRONE_COMMIT_AUTHOR="$CI_COMMIT_AUTHOR"
      -e DRONE_COMMIT_AUTHOR_EMAIL="$CI_COMMIT_AUTHOR_EMAIL"
      -e PLUGIN_SSH_KEY="$SSH_DEPLOY_KEY"
      -e PLUGIN_BRANCH=main
      -e PLUGIN_REMOTE=git@github.com:drycc/www.drycc.cc.git
      -e PLUGIN_FORCE=true
      -e PLUGIN_COMMIT=true
      -e PLUGIN_PATH=_build/html
      -e PLUGIN_COMMIT_MESSAGE="init repo"
      -v "$(pwd):$(pwd)"
      -w "$(pwd)"
      appleboy/drone-git-push
  secrets:
  - ssh_deploy_key
  when:
    event:
    - tag
    - push