You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
180 lines
3.6 KiB
180 lines
3.6 KiB
---
|
|
kind: pipeline
|
|
type: docker
|
|
name: build
|
|
|
|
trigger:
|
|
branch:
|
|
- main
|
|
event:
|
|
- push
|
|
- pull_request
|
|
- tag
|
|
|
|
clone:
|
|
skip_verify: true
|
|
|
|
steps:
|
|
- name: fetch
|
|
image: alpine/git
|
|
commands:
|
|
- git fetch --tags
|
|
|
|
- name: restore-cache
|
|
image: drillster/drone-volume-cache
|
|
volumes:
|
|
- name: cache
|
|
path: /cache
|
|
settings:
|
|
restore: true
|
|
mount:
|
|
- ./.yarn-cache
|
|
- ./node_modules
|
|
|
|
- name: yarn-install
|
|
image: node:14-alpine
|
|
commands:
|
|
- yarn --version
|
|
- yarn config set cache-folder .yarn-cache
|
|
- yarn install --pure-lockfile
|
|
depends_on: [fetch, restore-cache]
|
|
|
|
- name: build_frontend
|
|
image: node:14-alpine
|
|
commands:
|
|
- apk --no-cache add git
|
|
- yarn build
|
|
depends_on: [yarn-install]
|
|
|
|
- name: test
|
|
image: node:14-alpine
|
|
commands:
|
|
- yarn run test
|
|
depends_on: [build_frontend]
|
|
|
|
- name: lint
|
|
image: node:14-alpine
|
|
commands:
|
|
- yarn run lint
|
|
depends_on: [build_frontend]
|
|
|
|
- name: rebuild-cache
|
|
image: drillster/drone-volume-cache
|
|
volumes:
|
|
- name: cache
|
|
path: /cache
|
|
settings:
|
|
rebuild: true
|
|
mount:
|
|
- ./.yarn-cache
|
|
- ./node_modules
|
|
depends_on: [build_frontend, lint, test]
|
|
|
|
- name: notify-matrix
|
|
image: plugins/matrix
|
|
settings:
|
|
homeserver: https://matrix.chapo.chat
|
|
roomid: "!TjshsDXBWkOhmZIrmL:chapo.chat"
|
|
username:
|
|
from_secret: matrix_username
|
|
password:
|
|
from_secret: matrix_password
|
|
depends_on: [build_frontend, lint, test]
|
|
when:
|
|
status:
|
|
- success
|
|
- failure
|
|
|
|
volumes:
|
|
- name: cache
|
|
host:
|
|
path: /var/cache
|
|
|
|
---
|
|
kind: pipeline
|
|
type: docker
|
|
name: deploy
|
|
|
|
trigger:
|
|
event:
|
|
- promote
|
|
target:
|
|
- dev
|
|
- prod
|
|
|
|
clone:
|
|
skip_verify: true
|
|
|
|
globals:
|
|
- &docker_settings
|
|
username:
|
|
from_secret: CHAPO_REGISTRY_USER
|
|
password:
|
|
from_secret: CHAPO_REGISTRY_TOKEN
|
|
registry:
|
|
from_secret: CHAPO_REGISTRY_URL
|
|
repo:
|
|
from_secret: CHAPO_REGISTRY_URL_REPO
|
|
|
|
steps:
|
|
- name: fetch
|
|
image: alpine/git
|
|
commands:
|
|
- git fetch --tags
|
|
|
|
- name: prepare_docker_cache
|
|
image: busybox
|
|
commands:
|
|
- mkdir -p /cache/${DRONE_REPO}/docker
|
|
volumes:
|
|
- name: cache
|
|
path: /cache
|
|
|
|
- name: docker_build
|
|
image: plugins/docker
|
|
settings:
|
|
<<: *docker_settings
|
|
use_cache: true
|
|
dockerfile: docker/Dockerfile
|
|
tags:
|
|
- ${DRONE_DEPLOY_TO}-latest
|
|
- ${DRONE_BRANCH}
|
|
- ${DRONE_COMMIT_SHA:0:8}
|
|
- ${DRONE_BRANCH}-${DRONE_COMMIT}
|
|
- ${DRONE_DEPLOY_TO}-${DRONE_COMMIT}
|
|
cache_from:
|
|
- registry.chapo.chat/hexbear-frontend:${DRONE_BRANCH}
|
|
- registry.chapo.chat/hexbear-frontend:${DRONE_DEPLOY_TO}-latest
|
|
purge: false
|
|
volumes:
|
|
- name: docker
|
|
path: /var/lib/docker
|
|
- name: dockersock
|
|
path: /var/run/docker.sock
|
|
depends_on: [ fetch, prepare_docker_cache ]
|
|
|
|
- name: notify-matrix
|
|
image: plugins/matrix
|
|
settings:
|
|
homeserver: https://matrix.chapo.chat
|
|
roomid: "!TjshsDXBWkOhmZIrmL:chapo.chat"
|
|
username:
|
|
from_secret: matrix_username
|
|
password:
|
|
from_secret: matrix_password
|
|
depends_on: [docker_build]
|
|
when:
|
|
status:
|
|
- success
|
|
- failure
|
|
|
|
volumes:
|
|
- name: cache
|
|
host:
|
|
path: /var/cache
|
|
- name: docker
|
|
host:
|
|
path: /var/cache/${DRONE_REPO}/docker
|
|
- name: dockersock
|
|
host:
|
|
path: /var/run/docker.sock
|