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.

97 lines
3.3 KiB

  1. kind: pipeline
  2. name: build
  3. clone:
  4. depth: 1
  5. steps:
  6. - name: build
  7. image: docker.0k.io/0k-mirror-freezer
  8. volumes:
  9. - {name: docker, path: /var/run/docker.sock}
  10. settings:
  11. ## This key/known host are for git mirrors repos, and parent
  12. ## odoo_base repository.
  13. ssh_private_key: {from_secret: SSH_PRIVATE_KEY}
  14. ssh_known_hosts: {from_secret: SSH_KNOWN_HOSTS}
  15. ## This docker json should contain both mirror access and official
  16. ## final build docker repository access.
  17. docker_config_json: {from_secret: DOCKER_CONFIG_JSON}
  18. commands:
  19. - |
  20. echo "BUILDING ON: ${DRONE_SYSTEM_HOSTNAME}"
  21. - |
  22. mkdir -p /root/.ssh
  23. cat <<EOF > /root/.ssh/config
  24. Host git.0k.io
  25. User mirror
  26. Port 10022
  27. EOF
  28. - DEBUG=1 freeze docker.0k.io git.0k.io:/var/git/mirror
  29. - docker push "$(cat image)" ## this will push the new onbuild image
  30. - docker push "docker.0k.io/mirror/odoo/$(cat release)"
  31. - docker tag "docker.0k.io/mirror/odoo/$(cat
  32. release)" "docker.0k.io/mirror/odoo:${DRONE_COMMIT_BRANCH//\//_}"
  33. - docker push "docker.0k.io/mirror/odoo:${DRONE_COMMIT_BRANCH//\//_}"
  34. ## Warning: without 'ssh://', the port doesn't see to be used and it tries to
  35. ## connect to git.0k.io:22 (ssh fingerprint allows to infer this).
  36. - |
  37. release=$(cat release)
  38. git checkout -b "tmp"
  39. git commit -am "chg: pkg: release freezing in $release"
  40. git tag "release/candidate/$release"
  41. git push "${DRONE_GIT_SSH_URL}" "release/candidate/$release"
  42. - |
  43. release=$(cat release)
  44. echo "PUSHED DOCKER IMAGE: docker.0k.io/mirror/odoo/$release"
  45. echo "PUSHED GIT TAG: release/candidate/$release"
  46. - name: rocket
  47. ## mirror of ref: mike1pol/drone-rocket
  48. image: docker.0k.io/drone-rocket
  49. settings:
  50. url: {from_secret: ROCKETCHAT_URL}
  51. user_id: {from_secret: ROCKETCHAT_USER_ID}
  52. token: {from_secret: ROCKETCHAT_TOKEN}
  53. channel: "#odoo_releases"
  54. commands:
  55. - release=$(cat release)
  56. - |
  57. ## DRONE will substitute bash variables BEFORE bash
  58. export COMMIT_MESSAGE=$(echo -e ${DRONE_COMMIT_MESSAGE} | head -n 1)
  59. - |
  60. export MESSAGE="{{#success build.status}}✅{{else}}❌{{/success}} Build {{build.status}} \
  61. // *Summary:* $COMMIT_MESSAGE [ _${DRONE_COMMIT_AUTHOR_NAME}_ ]
  62. build: [{{build.number}}]({{build.link}}) / branch: \`{{build.branch}}\` / \
  63. commit: \`${DRONE_COMMIT_SHA:0:8}\`
  64. {{#success build.status}}
  65. *GIT TAG:* \`release/candidate/$release\` _(freezed version)_
  66. *DOCKER IMAGES:*
  67. - \`docker.0k.io/mirror/odoo/$release\` _(unique tag)_
  68. - \`docker.0k.io/mirror/odoo:${DRONE_COMMIT_BRANCH//\//_}\` _(floating reference)_
  69. Total Build time was $((DRONE_JOB_FINISHED - DRONE_JOB_STARTED))s
  70. {{/success}}"
  71. - rocket
  72. when:
  73. status:
  74. - success
  75. - failure
  76. volumes:
  77. - name: docker
  78. host:
  79. path: /var/run/docker.sock
  80. ## Need to configure secret 'dockerconfigjson' in drone secrets to
  81. ## hold a valid config.json file content. These secrets here allow
  82. ## to access 'docker.0k.io/*' images.
  83. image_pull_secrets:
  84. - dockerconfigjson
  85. trigger:
  86. branch:
  87. - test/*
  88. - rc/*
  89. - build/*
  90. node:
  91. instance: builder