homepage/.drone.yml
wanderer f5353973c2
All checks were successful
continuous-integration/drone/push Build is passing
general .drone.yml clean-up (#16)
refactor: positive rather than negative selection

* i.e. includes as opposed to excludes

chore: separate build and deploy pipeline

* this allows for more granular run conditions and constraints

refactor: remove redundant status==success assertion

Co-authored-by: surtur <a_mirre@utb.cz>
Reviewed-on: #16
Reviewed-by: dalahast <dalahast@noreply.git.dotya.ml>
Co-Authored-By: wanderer <wanderer@noreply.git.dotya.ml>
Co-Committed-By: wanderer <wanderer@noreply.git.dotya.ml>
2020-09-25 20:57:33 +02:00

196 lines
3.9 KiB
YAML

---
kind: pipeline
type: docker
name: pull
clone:
disable: true
steps:
- name: fedora-hugo
pull: always
image: immawanderer/fedora-hugo:latest
commands:
- uname -r
- cat /etc/fedora-release
- name: alpine-rsync
pull: always
image: immawanderer/alpine-rsync:latest
commands:
- uname -r
---
kind: pipeline
type: docker
name: build
platform:
os: linux
arch: amd64
depends_on:
- pull
steps:
- name: hugo-extended
pull: if-not-exists
image: immawanderer/fedora-hugo:latest
when:
branch:
- master
event:
- push
- pull_request
commands:
- git submodule init
- git submodule update
- hugo version
- hugo --gc=true --minify
---
kind: pipeline
type: docker
name: deploy
platform:
os: linux
arch: amd64
trigger:
event:
exclude:
- pull_request
- tag
depends_on:
- build
steps:
- name: hugo-extended
pull: if-not-exists
image: immawanderer/fedora-hugo:latest
commands:
- git submodule init
- git submodule update
- hugo version
- hugo --gc=true --minify
- name: deploy
pull: if-not-exists
image: immawanderer/alpine-rsync:latest
when:
status:
- success
branch:
- master
depends_on:
- hugo-extended
environment:
OL:
from_secret: hugo_user
OL_P:
from_secret: hugo_passwd
OL_D:
from_secret: hugo_dir
commands:
- echo $OL_P > nupass
- export RSYNC_RSH='sshpass -f ./nupass ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
- rsync -av --delete --chown $OL public/ $OL@dotya.ml:$OL_D
---
kind: pipeline
name: notifications
platform:
os: linux
arch: amd64
clone:
disable: true
trigger:
branch:
- master
- "*"
event:
- push
- tag
status:
- success
- failure
depends_on:
- deploy
steps:
- name: discord
pull: if-not-exists
image: appleboy/drone-discord:latest
settings:
message: >
{{#success build.status}}
✅ [Build #{{build.number}}]({{build.link}}) of `{{repo.name}}` has been successfully deployed.
event: **`{{build.event}}`**
commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}`
{{else}}
❌ [Build #{{build.number}}]({{build.link}}) of `{{repo.name}}` failed to deploy.
event: **`${DRONE_BUILD_EVENT}`**
failed stage(s): **`${DRONE_FAILED_STAGES}`**
commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}`
```{{commit.message}}```
{{/success}}
webhook_id:
from_secret: discord_webhook_id
webhook_token:
from_secret: discord_webhook_token
---
kind: pipeline
name: notifications-cron
platform:
os: linux
arch: amd64
clone:
disable: true
trigger:
event:
- cron
cron:
- hourly
- hourly-build
status:
- success
- failure
depends_on:
- deploy
steps:
- name: discord
pull: always
image: appleboy/drone-discord:latest
settings:
message: >
{{#success build.status}}
✅ [Hourly build #{{build.number}}]({{build.link}}) of `{{repo.name}}` has been successfully deployed.
event: **`{{build.event}}`**
commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}`
{{else}}
❌ [Hourly build #{{build.number}}]({{build.link}}) of `{{repo.name}}` failed to deploy.
event: **`${DRONE_BUILD_EVENT}`**
failed stage(s): **`${DRONE_FAILED_STAGES}`**
commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}`
```{{commit.message}}```
{{/success}}
webhook_id:
from_secret: discord_webhook_hourly_id
webhook_token:
from_secret: discord_webhook_hourly_token