Valentin Lab
4 years ago
1 changed files with 99 additions and 77 deletions
-
176.drone.yml
@ -1,97 +1,119 @@ |
|||
kind: pipeline |
|||
name: build |
|||
|
|||
|
|||
clone: |
|||
depth: 1 |
|||
|
|||
|
|||
steps: |
|||
- name: build |
|||
image: docker.0k.io/0k-mirror-freezer |
|||
volumes: |
|||
- {name: docker, path: /var/run/docker.sock} |
|||
settings: |
|||
## This key/known host are for git mirrors repos, and parent |
|||
## odoo_base repository. |
|||
ssh_private_key: {from_secret: SSH_PRIVATE_KEY} |
|||
ssh_known_hosts: {from_secret: SSH_KNOWN_HOSTS} |
|||
## This docker json should contain both mirror access and official |
|||
## final build docker repository access. |
|||
docker_config_json: {from_secret: DOCKER_CONFIG_JSON} |
|||
commands: |
|||
- | |
|||
echo "BUILDING ON: ${DRONE_SYSTEM_HOSTNAME}" |
|||
- | |
|||
mkdir -p /root/.ssh |
|||
cat <<EOF > /root/.ssh/config |
|||
Host git.0k.io |
|||
User mirror |
|||
Port 10022 |
|||
EOF |
|||
- DEBUG=1 freeze docker.0k.io git.0k.io:/var/git/mirror |
|||
- docker push "$(cat image)" ## this will push the new onbuild image |
|||
- docker push "docker.0k.io/mirror/odoo/$(cat release)" |
|||
- docker tag "docker.0k.io/mirror/odoo/$(cat |
|||
release)" "docker.0k.io/mirror/odoo:${DRONE_COMMIT_BRANCH//\//_}" |
|||
- docker push "docker.0k.io/mirror/odoo:${DRONE_COMMIT_BRANCH//\//_}" |
|||
## Warning: without 'ssh://', the port doesn't see to be used and it tries to |
|||
## connect to git.0k.io:22 (ssh fingerprint allows to infer this). |
|||
- | |
|||
release=$(cat release) |
|||
git checkout -b "tmp" |
|||
git commit -am "chg: pkg: release freezing in $release" |
|||
git tag "release/candidate/$release" |
|||
git push "${DRONE_GIT_SSH_URL}" "release/candidate/$release" |
|||
- | |
|||
release=$(cat release) |
|||
echo "PUSHED DOCKER IMAGE: docker.0k.io/mirror/odoo/$release" |
|||
echo "PUSHED GIT TAG: release/candidate/$release" |
|||
- name: rocket |
|||
## mirror of ref: mike1pol/drone-rocket |
|||
image: docker.0k.io/drone-rocket |
|||
settings: |
|||
url: {from_secret: ROCKETCHAT_URL} |
|||
user_id: {from_secret: ROCKETCHAT_USER_ID} |
|||
token: {from_secret: ROCKETCHAT_TOKEN} |
|||
channel: "#odoo_releases" |
|||
commands: |
|||
- release=$(cat release) |
|||
- | |
|||
## DRONE will substitute bash variables BEFORE bash |
|||
export COMMIT_MESSAGE=$(echo -e ${DRONE_COMMIT_MESSAGE} | head -n 1) |
|||
- | |
|||
export MESSAGE="{{#success build.status}}✅{{else}}❌{{/success}} Build {{build.status}} \ |
|||
// *Summary:* $COMMIT_MESSAGE [ _${DRONE_COMMIT_AUTHOR_NAME}_ ] |
|||
build: [{{build.number}}]({{build.link}}) / branch: \`{{build.branch}}\` / \ |
|||
commit: \`${DRONE_COMMIT_SHA:0:8}\` |
|||
{{#success build.status}} |
|||
*GIT TAG:* \`release/candidate/$release\` _(freezed version)_ |
|||
*DOCKER IMAGES:* |
|||
- \`docker.0k.io/mirror/odoo/$release\` _(unique tag)_ |
|||
- \`docker.0k.io/mirror/odoo:${DRONE_COMMIT_BRANCH//\//_}\` _(floating reference)_ |
|||
Total Build time was $((DRONE_JOB_FINISHED - DRONE_JOB_STARTED))s |
|||
{{/success}}" |
|||
- rocket |
|||
when: |
|||
status: |
|||
- success |
|||
- failure |
|||
|
|||
- name: build |
|||
image: docker.0k.io/0k-mirror-freezer |
|||
volumes: |
|||
- {name: docker, path: /var/run/docker.sock} |
|||
settings: |
|||
## This key/known host are for git mirrors repos, and parent |
|||
## odoo_base repository. |
|||
ssh_private_key: {from_secret: SSH_PRIVATE_KEY} |
|||
ssh_known_hosts: {from_secret: SSH_KNOWN_HOSTS} |
|||
## This docker json should contain both mirror access and official |
|||
## final build docker repository access. |
|||
docker_config_json: {from_secret: DOCKER_CONFIG_JSON} |
|||
commands: |
|||
- | |
|||
ip=$(curl -q myip.kal.fr 2>/dev/null) |
|||
name=$(dig -x "$ip" +short) |
|||
echo "===== BUILDING ON: ${DRONE_SYSTEM_HOSTNAME}" |
|||
echo "===== SLAVE: $name ($ip)" |
|||
- | |
|||
mkdir -p /root/.ssh |
|||
cat <<EOF > /root/.ssh/config |
|||
Host git.0k.io |
|||
User mirror |
|||
Port 10022 |
|||
EOF |
|||
- DEBUG=1 freeze docker.0k.io git.0k.io:/var/git/mirror |
|||
- | |
|||
echo "====== PUSHING onbuild freezed (and patched) IMAGE: $(cat image)" |
|||
docker push "$(cat image)" ## this will push the new onbuild image |
|||
- | |
|||
image="docker.0k.io/mirror/odoo:${DRONE_COMMIT_BRANCH//\//_}" |
|||
release="docker.0k.io/mirror/odoo/$(cat release)" |
|||
echo "PUSHING IMAGE: $release" |
|||
docker push "$release" |
|||
echo "TAGGING AND PUSHING: $image" |
|||
docker tag "$release" "$image" |
|||
docker push "$image" |
|||
## Warning: without 'ssh://', the port doesn't see to be used and it tries to |
|||
## connect to git.0k.io:22 (ssh fingerprint allows to infer this). |
|||
- | |
|||
release=$(cat release) |
|||
git checkout -b "tmp" |
|||
git commit -am "chg: pkg: release freezing in $release" |
|||
git tag "release/candidate/$release" |
|||
git push "${DRONE_GIT_SSH_URL}" "release/candidate/$release" |
|||
- | |
|||
release=$(cat release) |
|||
echo "PUSHED DOCKER IMAGE: docker.0k.io/mirror/odoo/$release" |
|||
echo "PUSHED GIT TAG: release/candidate/$release" |
|||
- name: rocket |
|||
## mirror of ref: mike1pol/drone-rocket |
|||
image: docker.0k.io/drone-rocket |
|||
settings: |
|||
url: {from_secret: ROCKETCHAT_URL} |
|||
user_id: {from_secret: ROCKETCHAT_USER_ID} |
|||
token: {from_secret: ROCKETCHAT_TOKEN} |
|||
channel: '#odoo_releases' |
|||
commands: |
|||
- release=$(cat release) |
|||
- | |
|||
## DRONE will substitute bash variables BEFORE bash |
|||
export COMMIT_MESSAGE=$(echo -e ${DRONE_COMMIT_MESSAGE} | head -n 1) |
|||
- | |
|||
## DRONE will wrongly try to display the code of this step, actually |
|||
## running things in backticks to display " + command " on stdout. |
|||
## Mainly because it didn't quote backticks, but quoted backslash. |
|||
## Drone actually run this docker by injecting a /usr/drone/bin/init |
|||
## with code from these commands, but also an 'echo + command' line |
|||
## just before. |
|||
## This won't have any consequences in this step apart from annoying |
|||
## error messages in drone step output |
|||
export MESSAGE="{{#success build.status}}✅{{else}}❌{{/success}} Build {{build.status}} \ |
|||
// *Summary:* $COMMIT_MESSAGE [ _${DRONE_COMMIT_AUTHOR_NAME}_ ] |
|||
build: [{{build.number}}]({{build.link}}) / branch: \`{{build.branch}}\` / \ |
|||
commit: \`${DRONE_COMMIT_SHA:0:8}\` |
|||
{{#success build.status}} |
|||
*GIT TAG:* \`release/candidate/$release\` _(freezed version)_ |
|||
*DOCKER IMAGES:* |
|||
- \`docker.0k.io/mirror/odoo/$release\` _(unique tag)_ |
|||
- \`docker.0k.io/mirror/odoo:${DRONE_COMMIT_BRANCH//\//_}\` _(floating reference)_ |
|||
Total Build time was $((DRONE_JOB_FINISHED - DRONE_JOB_STARTED))s |
|||
{{/success}}" |
|||
- rocket |
|||
when: |
|||
status: |
|||
- success |
|||
- failure |
|||
|
|||
|
|||
|
|||
volumes: |
|||
- name: docker |
|||
host: |
|||
path: /var/run/docker.sock |
|||
- name: docker |
|||
host: |
|||
path: /var/run/docker.sock |
|||
|
|||
## Need to configure secret 'dockerconfigjson' in drone secrets to |
|||
## hold a valid config.json file content. These secrets here allow |
|||
## to access 'docker.0k.io/*' images. |
|||
image_pull_secrets: |
|||
- dockerconfigjson |
|||
- dockerconfigjson |
|||
|
|||
trigger: |
|||
branch: |
|||
- test/* |
|||
- rc/* |
|||
- build/* |
|||
- test/* |
|||
- rc/* |
|||
- build/* |
|||
|
|||
node: |
|||
instance: builder |
Write
Preview
Loading…
Cancel
Save
Reference in new issue