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.

119 lines
4.0 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. ip=$(curl -q myip.kal.fr 2>/dev/null)
  21. name=$(dig -x "$ip" +short)
  22. echo "===== BUILDING ON: ${DRONE_SYSTEM_HOSTNAME}"
  23. echo "===== SLAVE: $name ($ip)"
  24. - |
  25. mkdir -p /root/.ssh
  26. cat <<EOF > /root/.ssh/config
  27. Host git.0k.io
  28. User mirror
  29. Port 10022
  30. EOF
  31. - DEBUG=1 freeze docker.0k.io git.0k.io:/var/git/mirror
  32. - |
  33. echo "====== PUSHING onbuild freezed (and patched) IMAGE: $(cat image)"
  34. docker push "$(cat image)" ## this will push the new onbuild image
  35. - |
  36. image="docker.0k.io/mirror/odoo:${DRONE_COMMIT_BRANCH//\//_}"
  37. release="docker.0k.io/mirror/odoo/$(cat release)"
  38. echo "PUSHING IMAGE: $release"
  39. docker push "$release"
  40. echo "TAGGING AND PUSHING: $image"
  41. docker tag "$release" "$image"
  42. docker push "$image"
  43. ## Warning: without 'ssh://', the port doesn't see to be used and it tries to
  44. ## connect to git.0k.io:22 (ssh fingerprint allows to infer this).
  45. - |
  46. release=$(cat release)
  47. git checkout -b "tmp"
  48. git commit -am "chg: pkg: release freezing in $release"
  49. git tag "release/candidate/$release"
  50. git push "${DRONE_GIT_SSH_URL}" "release/candidate/$release"
  51. - |
  52. release=$(cat release)
  53. echo "PUSHED DOCKER IMAGE: docker.0k.io/mirror/odoo/$release"
  54. echo "PUSHED GIT TAG: release/candidate/$release"
  55. - name: rocket
  56. ## mirror of ref: mike1pol/drone-rocket
  57. image: docker.0k.io/drone-rocket
  58. settings:
  59. url: {from_secret: ROCKETCHAT_URL}
  60. user_id: {from_secret: ROCKETCHAT_USER_ID}
  61. token: {from_secret: ROCKETCHAT_TOKEN}
  62. channel: '#odoo_releases'
  63. commands:
  64. - release=$(cat release)
  65. - |
  66. ## DRONE will substitute bash variables BEFORE bash
  67. export COMMIT_MESSAGE=$(echo -e ${DRONE_COMMIT_MESSAGE} | head -n 1)
  68. - |
  69. ## DRONE will wrongly try to display the code of this step, actually
  70. ## running things in backticks to display " + command " on stdout.
  71. ## Mainly because it didn't quote backticks, but quoted backslash.
  72. ## Drone actually run this docker by injecting a /usr/drone/bin/init
  73. ## with code from these commands, but also an 'echo + command' line
  74. ## just before.
  75. ## This won't have any consequences in this step apart from annoying
  76. ## error messages in drone step output
  77. export MESSAGE="{{#success build.status}}✅{{else}}❌{{/success}} Build {{build.status}} \
  78. // *Summary:* $COMMIT_MESSAGE [ _${DRONE_COMMIT_AUTHOR_NAME}_ ]
  79. build: [{{build.number}}]({{build.link}}) / branch: \`{{build.branch}}\` / \
  80. commit: \`${DRONE_COMMIT_SHA:0:8}\`
  81. {{#success build.status}}
  82. *GIT TAG:* \`release/candidate/$release\` _(freezed version)_
  83. *DOCKER IMAGES:*
  84. - \`docker.0k.io/mirror/odoo/$release\` _(unique tag)_
  85. - \`docker.0k.io/mirror/odoo:${DRONE_COMMIT_BRANCH//\//_}\` _(floating reference)_
  86. Total Build time was $((DRONE_JOB_FINISHED - DRONE_JOB_STARTED))s
  87. {{/success}}"
  88. - rocket
  89. when:
  90. status:
  91. - success
  92. - failure
  93. volumes:
  94. - name: docker
  95. host:
  96. path: /var/run/docker.sock
  97. ## Need to configure secret 'dockerconfigjson' in drone secrets to
  98. ## hold a valid config.json file content. These secrets here allow
  99. ## to access 'docker.0k.io/*' images.
  100. image_pull_secrets:
  101. - dockerconfigjson
  102. trigger:
  103. branch:
  104. - test/*
  105. - rc/*
  106. - build/*
  107. node:
  108. instance: builder