core/.drone.yml
mahdi 11906a9d02
Some checks failed
continuous-integration/drone/push Build is failing
devops - drone test failure build
2023-12-15 23:57:09 +01:00

85 lines
2.6 KiB
YAML

kind: pipeline
type: docker
name: default
steps:
- name: test
image: golang
volumes:
- name: deps
path: /go
commands:
- go test ./...
- name: build
image: golang
volumes:
- name: deps
path: /go
commands:
- go build -v -race -a ./...
- name: deploy
image: alpine
volumes:
- name: ssh_key
path: /root/.ssh
commands:
- chmod 0400 /root/.ssh/id_rsa.kubehost
- ls -lah /root/.ssh/id_rsa.kubehost
- apk add --no-cache openssh
- ssh -p21022 -o StrictHostKeyChecking=accept-new -i /root/.ssh/id_rsa.kubehost mtc@bosub-kub-int.metacoaching.pro "hostname"
- name: notify fail
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
- printenv
- 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}
- 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
- 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
- printenv
- 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