You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.3 KiB

4 years ago
  1. ---
  2. resources:
  3. - name: git-resource
  4. type: git
  5. icon: git
  6. source:
  7. uri: ssh://git@git.nulloctet.com:8437/nulloctet/blog-nulloctet-com.git
  8. private_key: |
  9. ((pull_key))
  10. ignore_paths:
  11. - pipeline.yml
  12. - upload_pipeline.sh
  13. - README.md
  14. branch: master
  15. jobs:
  16. - name: publish
  17. plan:
  18. - get: git-resource
  19. trigger: true
  20. - task: build-site
  21. config:
  22. platform: linux
  23. image_resource:
  24. type: registry-image
  25. source:
  26. repository: ((nexus_docker_read.host))/sothr/hugo
  27. username: ((nexus_docker_read.username))
  28. password: ((nexus_docker_read.password))
  29. inputs:
  30. - name: git-resource
  31. outputs:
  32. - name: site-html
  33. params:
  34. HUGO_THEME: hyde
  35. HUGO_BASEURL: https://blog.nulloctet.com/
  36. run:
  37. path: /bin/sh
  38. args:
  39. - -c
  40. - |
  41. export HUGO_SOURCE="${PWD}/git-resource"
  42. /run.sh --minify
  43. tar -czvf site-html/website.tgz -C /output/ .
  44. - task: publish-site
  45. config:
  46. platform: linux
  47. image_resource:
  48. type: registry-image
  49. source:
  50. repository: ((nexus_docker_read.host))/sothr/deploy
  51. tag: "stable"
  52. username: ((nexus_docker_read.username))
  53. password: ((nexus_docker_read.password))
  54. inputs:
  55. - name: site-html
  56. params:
  57. DEPLOY_KEY: ((deploy.key))
  58. DEPLOY_HOST: ((deploy.host))
  59. DEPLOY_PORT: ((deploy.port))
  60. DEPLOY_USER: ((deploy.user))
  61. DEPLOY_TARGET: ((deploy.target))
  62. run:
  63. path: /bin/bash
  64. args:
  65. - -c
  66. - |
  67. eval `ssh-agent -s`
  68. ssh-add <(echo "${DEPLOY_KEY}")
  69. mkdir -p ~/.ssh
  70. ssh-keyscan -p ${DEPLOY_PORT} ${DEPLOY_HOST} >> ~/.ssh/known_hosts
  71. mkdir /tmp/deploy
  72. tar -xzvf site-html/website.tgz -C /tmp/deploy
  73. rsync -avz --delete-delay -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p ${DEPLOY_PORT}" --progress /tmp/deploy/* ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_TARGET}