.drone.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. kind: pipeline
  2. name: default
  3. steps:
  4. - name: unit-test
  5. image: python:3.9.9-slim
  6. commands:
  7. - pip install poetry
  8. - poetry install
  9. - poetry run pytest ./tests/
  10. volumes:
  11. - name: cache-pip
  12. path: /root/.cache/pip
  13. - name: cache-poetry
  14. path: /root/.cache/pypoetry
  15. - name: build-only
  16. image: plugins/docker
  17. settings:
  18. repo: docker.snas.black-burn.ch/${DRONE_REPO_NAMESPACE,,}/${DRONE_REPO_NAME,,}
  19. dry_run: true
  20. volumes:
  21. - name: docker_sock
  22. path: /var/run/docker.sock
  23. when:
  24. ref:
  25. exclude:
  26. - refs/tags/*
  27. - name: build-and-push
  28. image: plugins/docker
  29. settings:
  30. username:
  31. from_secret: NUCNAS_DOCKER_USERNAME
  32. password:
  33. from_secret: NUCNAS_DOCKER_PASSWORD
  34. repo: docker.snas.black-burn.ch/${DRONE_REPO_NAMESPACE,,}/${DRONE_REPO_NAME,,}
  35. registry: docker.snas.black-burn.ch
  36. volumes:
  37. - name: docker_sock
  38. path: /var/run/docker.sock
  39. when:
  40. ref:
  41. - refs/tags/*
  42. - name: discord notification
  43. image: appleboy/drone-discord
  44. when:
  45. status:
  46. - failure
  47. - success
  48. settings:
  49. username: drone-ci
  50. webhook_id:
  51. from_secret: DISCORD_WEBHOOK_ID
  52. webhook_token:
  53. from_secret: DISCORD_WEBHOOK_TOKEN
  54. message: >
  55. {{#success build.status}}
  56. :green_square: {{repo.name}} #{{build.number}}
  57. {{commit.branch}} / {{truncate commit.sha 8}} / {{commit.author}}
  58. Build succeeded!
  59. {{else}}
  60. :red_square: {{repo.name}} #{{build.number}}
  61. {{commit.branch}} / {{truncate commit.sha 8}} / {{commit.author}}
  62. Build failed!
  63. {{/success}}
  64. volumes:
  65. - name: docker_sock
  66. host:
  67. path: /var/run/docker.sock
  68. - name: cache-pip
  69. host:
  70. path: /tmp/drone/cache/pip
  71. - name: cache-poetry
  72. host:
  73. path: /tmp/drone/cache/poetry