core/.drone.yml

87 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
2023-12-15 22:49:37 +00:00
- name: 2. test
2023-12-12 22:55:19 +00:00
image: golang
volumes:
- name: deps
path: /go
commands:
- go test ./...
2023-12-15 22:49:37 +00:00
- name: 3. build
2023-12-12 22:55:19 +00:00
image: golang
volumes:
- name: deps
path: /go
commands:
2023-12-15 22:49:37 +00:00
- go build -v -race -a ./...
2023-12-12 22:55:19 +00:00
2023-12-15 22:49:37 +00:00
- name: 4. deploy
2023-12-14 00:33:04 +00:00
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-15 22:49:37 +00:00
- name: 5. notify fail
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-15 22:49:37 +00:00
- printenv
2023-12-14 23:43:00 +00:00
- export ZULIP_STATUS=":prohibited:"
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}
2023-12-15 23:14:06 +00:00
- export REMOTE_URL=$${DRONE_REMOTE_URL:0:-4}
- export ZULIP_FAILED_STEPS=$${DRONE_FAILED_STEPS}
- 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> ***failed at $ZULIP_FAILED_STEPS*** %0A> $ZULIP_MESSAGE"
2023-12-14 23:13:40 +00:00
when:
status:
- failure
2023-12-14 23:43:00 +00:00
2023-12-15 22:49:37 +00:00
- name: 5. notify done
2023-12-14 23:43:00 +00:00
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
2023-12-15 22:49:37 +00:00
- printenv
2023-12-14 23:43:00 +00:00
- 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