Created
December 9, 2018 15:49
-
-
Save gyengus/5c7446f6bc505df2ea30ebdb8a039a7f to your computer and use it in GitHub Desktop.
Gitlab CI config for Home Assistant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- test | |
- deploy | |
- notify | |
test: | |
stage: test | |
image: homeassistant/amd64-homeassistant:0.83.3 | |
before_script: | |
- hass --version | |
script: | |
- hass --script check_config -c . | |
deploy: | |
stage: deploy | |
only: | |
- master | |
tags: | |
- inner | |
before_script: | |
- 'which ssh-agent || ( apk update && apk add openssh-client )' | |
- eval $(ssh-agent -s) | |
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null | |
- mkdir -p ~/.ssh | |
- chmod 700 ~/.ssh | |
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts | |
- chmod 644 ~/.ssh/known_hosts | |
script: | |
- ssh -tt $DEPLOY_USER@$DEPLOY_HOST "cd '$DEPLOY_PATH'; git pull; /etc/init.d/hass-daemon restart" | |
notify_success: | |
stage: notify | |
allow_failure: true | |
only: | |
- master | |
before_script: | |
- apk update | |
- apk add curl | |
script: | |
- "curl -X POST -H \"Content-Type: application/json\" -d '{\"value1\":\"Home Assistant successfully deployed :).\"}' https://maker.ifttt.com/trigger/$IFTTT_EVENT/with/key/$IFTTT_KEY" | |
- echo '\n' | |
notify_fail: | |
stage: notify | |
allow_failure: true | |
only: | |
- master | |
when: on_failure | |
before_script: | |
- apk update | |
- apk add curl | |
script: | |
- "curl -X POST -H \"Content-Type: application/json\" -d '{\"value1\":\"Home Assistant build and/or deploy failed :(.\"}' https://maker.ifttt.com/trigger/$IFTTT_EVENT/with/key/$IFTTT_KEY" | |
- echo '\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment