---
kind: pipeline
name: build

platform:
  os: linux
  arch: amd64

concurrency:
  limit: 1

steps:
  - name: generate
    image: thegeeklab/alpine-tools
    commands:
      - make doc

  - name: markdownlint
    image: thegeeklab/markdownlint-cli
    commands:
      - markdownlint 'content/**/*.md' 'README.md'

  - name: spellcheck
    image: thegeeklab/alpine-tools
    commands:
      - spellchecker --files 'content/**/*.md' 'README.md' -d .dictionary -p spell indefinite-article syntax-urls frontmatter --frontmatter-keys title tags --no-suggestions
    environment:
      FORCE_COLOR: true
      NPM_CONFIG_LOGLEVEL: error

  - name: favicons
    image: node:lts-alpine
    commands:
      - npm install > /dev/null
      - npm run build
    environment:
      FORCE_COLOR: true
      NPM_CONFIG_LOGLEVEL: error

  - name: testbuild
    image: thegeeklab/hugo:0.115.2
    commands:
      - hugo --panicOnWarning -b http://localhost:8000/

  - name: link-validation
    image: lycheeverse/lychee
    commands:
      - lychee --no-progress --format detailed content/ README.md

  - name: build
    image: thegeeklab/hugo:0.115.2
    commands:
      - hugo --panicOnWarning

  - name: beautify
    image: node:lts-alpine
    commands:
      - npm install -g js-beautify
      - html-beautify -r -f 'public/**/*.html'
    environment:
      FORCE_COLOR: true
      NPM_CONFIG_LOGLEVEL: error

  - name: publish
    image: thegeeklab/drone-s3-sync:2
    settings:
      access_key:
        from_secret: s3_access_key
      bucket: thegeeklab-root
      delete: true
      endpoint:
        from_secret: s3_endpoint
      path_style: true
      secret_key:
        from_secret: s3_secret_access_key
      source: public/
      strip_prefix: public/
    when:
      ref:
        - refs/heads/main
        - refs/tags/**

trigger:
  ref:
    - refs/heads/main
    - refs/tags/**
    - refs/pull/**

---
kind: pipeline
name: notifications

platform:
  os: linux
  arch: amd64

steps:
  - name: matrix
    image: thegeeklab/drone-matrix
    settings:
      homeserver:
        from_secret: matrix_homeserver
      password:
        from_secret: matrix_password
      roomid:
        from_secret: matrix_roomid
      template: "Status: **{{ .Build.Status }}**<br/> Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}<br/> Message: {{ .Commit.Message.Title }}"
      username:
        from_secret: matrix_username
    when:
      status:
        - success
        - failure

trigger:
  ref:
    - refs/heads/main
    - refs/tags/**
  status:
    - success
    - failure

depends_on:
  - build

---
kind: signature
hmac: 899894369ae1a6044074429d797c0fb8a558ec7bf5535f25fffc8266064b0ea1

...
