---
# drone encrypt weko/histoiredunpied $AWS_ACCESS_KEY_ID
kind: secret
name: PRODUCTION_AWS_ACCESS_KEY_ID
data: /xI53R4q+LG5Hyo4m58pqTkwAtRXwRq81J4xdgjNrKIjsMdr9tZ+WQDU9UDlQ6AmbiVPgB03

---
# drone encrypt weko/histoiredunpied $AWS_SECRET_ACCESS_KEY
kind: secret
name: PRODUCTION_AWS_SECRET_ACCESS_KEY
data: s8r0O9MmAlItowihl8mpx5BfoBwpTngxnIjATbkwpBadx3K3vPoClO9f4I1sfRl8ANn84Jp8VioMynvNUyw1+283O0qmMtvLPm54KZ4fqh/pxJoT35lur/2hKug=

---
kind: pipeline
type: docker
name: default

platform:
  os: linux
  arch: arm64

steps:
- name: install submodule
  image: drone/git
  commands:
  - git submodule update --init

- name: install npm
  image: node:current-alpine
  volumes:
  - name: hugo-theme-lowtech_node_modules
    path: /drone/src/themes/hugo-theme-lowtech/node_modules
  - name: hugo-node_modules
    path: /drone/src/node_modules
  commands:
  - npm i
  - (cd themes/hugo-theme-lowtech && npm i)

- name: build website
  image: klakegg/hugo:0.107.0-ext-debian-ci
  commands:
    - hugo --minify --environment production

- name: Typo + purgecss
  image: node:current-alpine
  volumes:
  - name: hugo-theme-lowtech_node_modules
    path: /drone/src/themes/hugo-theme-lowtech/node_modules
  - name: hugo-node_modules
    path: /drone/src/node_modules
  commands:
  - node themes/hugo-theme-lowtech/scripts/typo
  - node_modules/.bin/purgecss --css public/css/*.css --content public/index.html --output public/css/

- name: deploy
  image: klakegg/hugo:0.107.0-ext-debian-ci
  environment:
    AWS_ACCESS_KEY_ID:
      from_secret: PRODUCTION_AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY:
      from_secret: PRODUCTION_AWS_SECRET_ACCESS_KEY
  commands:
    - hugo deploy --environment production
  when:
    branch:
    - master

trigger:
  event:
    - push
  branch:
    - master

volumes:
- name: hugo-theme-lowtech_node_modules
  host:
    path: /tmp/drone/cache/weko/histoiredunpied_com/themes/hugo-theme-lowtech
- name: hugo-node_modules
  host:
    path: /tmp/drone/cache/weko/histoiredunpied_com/node_modules
