diff --git a/.drone.yml b/.drone.yml index 22f71d1..93cf8ab 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,11 +3,6 @@ type: docker name: default steps: -- name: greeting - image: alpine - commands: - - echo hello - - echo world - name: test image: golang @@ -38,7 +33,7 @@ steps: # script: # - echo "Target host name :\ `hostname`" -- name: test volumes +- name: test deploy image: alpine volumes: - name: ssh_key @@ -49,19 +44,7 @@ steps: - apk add --no-cache openssh - ssh -p21022 -o StrictHostKeyChecking=accept-new -i /root/.ssh/id_rsa.kubehost mtc@bosub-kub-int.metacoaching.pro "hostname" -volumes: -- name: deps - temp: {} -- name: ssh_key - host: - path: /home/repo/drone - ---- -kind: pipeline -name: after - -steps: -- name: notify +- name: notify fail image: bash:4.4 environment: ZULIP_HOST: https://zulip.meta-tech.academy @@ -74,31 +57,40 @@ steps: from_secret: ZULIP_TOKEN commands: - apk add --no-cache curl - - if [ "${DRONE_BUILD_STATUS}" != "success" ]; then export ZULIP_STATUS=":prohibited:"; fi + - export ZULIP_STATUS=":prohibited:" - export ZULIP_MESSAGE=$${DRONE_COMMIT_MESSAGE:-2} - export SHORT_COMMIT=$${DRONE_COMMIT:0:7} - export REMOTE_URL=$${DRONE_REMOTE_URL:0:-4} - - echo $SHORT_COMMIT - - echo $ZULIP_STATUS - - echo $ZULIP_MESSAGE - - echo $REMOTE_URL - - echo " ================================= " - - echo "DRONE_BUILD_ACTION ${DRONE_BUILD_ACTION}" - - echo "DRONE_BUILD_CREATED ${DRONE_BUILD_CREATED}" - - echo "DRONE_BUILD_EVENT ${DRONE_BUILD_EVENT}" - - echo "DRONE_BUILD_FINISHED ${DRONE_BUILD_FINISHED}" - - echo "DRONE_BUILD_NUMBER ${DRONE_BUILD_NUMBER}" - - echo "DRONE_BUILD_LINK ${DRONE_BUILD_LINK}" - - echo "DRONE_BUILD_PARENT ${DRONE_BUILD_PARENT}" - - echo "DRONE_BUILD_STARTED ${DRONE_BUILD_STARTED}" - - echo "DRONE_BUILD_STATUS ${DRONE_BUILD_STATUS}" - - echo "DRONE_BUILD_TRIGGER ${DRONE_BUILD_TRIGGER}" - - echo "DRONE_FAILED_STAGES ${DRONE_FAILED_STAGES}" - - echo "DRONE_FAILED_STEPS ${DRONE_FAILED_STEPS}" - - echo " ================================= " - - echo ok - - curl -X POST "$ZULIP_HOST/api/v1/messages" -u "$ZULIP_USER:$ZULIP_TKN" --data-urlencode "type=stream" --data-urlencode "to=\"$ZULIP_STREAM\"" --data-urlencode "topic=$ZULIP_TOPIC" --data "content=$ZULIP_STATUS **[build %23${DRONE_BUILD_NUMBER}](${DRONE_BUILD_LINK})**%0A> **${DRONE_BUILD_EVENT}** event on **${DRONE_COMMIT_BRANCH}** branch *by* **${DRONE_COMMIT_AUTHOR}** ([$SHORT_COMMIT]($REMOTE_URL/commit/${DRONE_COMMIT}))%0A> $ZULIP_MESSAGE" + - curl -s -X POST "$ZULIP_HOST/api/v1/messages" -u "$ZULIP_USER:$ZULIP_TKN" --data-urlencode "type=stream" --data-urlencode "to=\"$ZULIP_STREAM\"" --data-urlencode "topic=$ZULIP_TOPIC" --data "content=$ZULIP_STATUS **[build %23${DRONE_BUILD_NUMBER}](${DRONE_BUILD_LINK})**%0A> **${DRONE_BUILD_EVENT}** event on **${DRONE_COMMIT_BRANCH}** branch *by* **${DRONE_COMMIT_AUTHOR}** ([$SHORT_COMMIT]($REMOTE_URL/commit/${DRONE_COMMIT}))%0A> $ZULIP_MESSAGE" when: status: - failure - - success \ No newline at end of file + +- name: notify done + image: bash:4.4 + environment: + ZULIP_HOST: https://zulip.meta-tech.academy + ZULIP_STREAM: gitea + ZULIP_TOPIC: build + ZULIP_STATUS: ":check:" + ZULIP_USER: + from_secret: ZULIP_BOT + ZULIP_TKN: + from_secret: ZULIP_TOKEN + commands: + - apk add --no-cache curl + - export ZULIP_STATUS=":check:" + - export ZULIP_MESSAGE=$${DRONE_COMMIT_MESSAGE:-2} + - export SHORT_COMMIT=$${DRONE_COMMIT:0:7} + - export REMOTE_URL=$${DRONE_REMOTE_URL:0:-4} + - curl -s -X POST "$ZULIP_HOST/api/v1/messages" -u "$ZULIP_USER:$ZULIP_TKN" --data-urlencode "type=stream" --data-urlencode "to=\"$ZULIP_STREAM\"" --data-urlencode "topic=$ZULIP_TOPIC" --data "content=$ZULIP_STATUS **[build %23${DRONE_BUILD_NUMBER}](${DRONE_BUILD_LINK})**%0A> **${DRONE_BUILD_EVENT}** event on **${DRONE_COMMIT_BRANCH}** branch *by* **${DRONE_COMMIT_AUTHOR}** ([$SHORT_COMMIT]($REMOTE_URL/commit/${DRONE_COMMIT}))%0A> $ZULIP_MESSAGE" + when: + status: + - success + +volumes: +- name: deps + temp: {} +- name: ssh_key + host: + path: /home/repo/drone \ No newline at end of file