core/.drone.yml

98 lines
2.8 KiB
YAML
Raw Normal View History

2023-12-12 22:55:19 +00:00
kind: pipeline
2023-12-12 22:59:18 +00:00
type: docker
2023-12-12 22:55:19 +00:00
name: default
steps:
2023-12-12 22:59:18 +00:00
- name: greeting
image: alpine
commands:
- echo hello
- echo world
2023-12-12 22:55:19 +00:00
- name: test
image: golang
volumes:
- name: deps
path: /go
commands:
- go test ./...
- name: build
image: golang
volumes:
- name: deps
path: /go
commands:
- go build ./...
2023-12-14 00:33:04 +00:00
# - name: deploy code
# image: appleboy/drone-ssh
# volumes:
# - name: ssh_key
# path: /root/.ssh
# settings:
# host: bosub-kub-int.metacoaching.pro
# username: mtc
# port: 21022
# key_path: /root/.ssh/id_rsa.kubehost
# script:
# - echo "Target host name :\ `hostname`"
- name: test volumes
image: alpine
2023-12-13 23:58:24 +00:00
volumes:
2023-12-14 00:22:13 +00:00
- name: ssh_key
2023-12-14 00:23:55 +00:00
path: /root/.ssh
2023-12-14 00:33:04 +00:00
commands:
2023-12-14 00:49:38 +00:00
- chmod 0400 /root/.ssh/id_rsa.kubehost
- ls -lah /root/.ssh/id_rsa.kubehost
2023-12-14 00:36:52 +00:00
- apk add --no-cache openssh
2023-12-14 00:54:23 +00:00
- ssh -p21022 -o StrictHostKeyChecking=accept-new -i /root/.ssh/id_rsa.kubehost mtc@bosub-kub-int.metacoaching.pro "hostname"
2023-12-13 23:52:09 +00:00
2023-12-14 22:02:27 +00:00
- name: notify
2023-12-14 22:35:55 +00:00
image: bash:4.4
2023-12-14 22:02:27 +00:00
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:
2023-12-14 22:35:55 +00:00
- apk add --no-cache curl
2023-12-14 22:26:11 +00:00
- if [ "${DRONE_BUILD_STATUS}" != "success" ]; then export ZULIP_STATUS=":prohibited:"; fi
2023-12-14 22:43:56 +00:00
- 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
2023-12-14 23:18:53 +00:00
- echo "FAILED STEPS ${DRONE_FAILED_STEPS}"
2023-12-14 23:23:41 +00:00
- 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 " ================================= "
2023-12-14 22:43:56 +00:00
- echo ok
2023-12-14 22:46:49 +00:00
- 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"
2023-12-14 23:13:40 +00:00
when:
status:
- failure
- success
2023-12-14 22:52:41 +00:00
2023-12-12 22:55:19 +00:00
volumes:
- name: deps
2023-12-13 23:58:24 +00:00
temp: {}
2023-12-14 00:14:24 +00:00
- name: ssh_key
host:
2023-12-14 00:23:55 +00:00
path: /home/repo/drone