Drone: initial builds
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
Garrett Mills 2022-11-29 17:18:23 -06:00
parent 1b1c1f5f5e
commit c1c768e8b3
2 changed files with 542 additions and 308 deletions

View File

@ -1,200 +1,47 @@
---
kind: pipeline
name: default
type: docker
steps:
# ============ RESTORE CACHE =============
# - name: restore node_modules cache
# image: appleboy/drone-sftp-cache
# settings:
# server:
# from_secret: cache_server
# port: 22
# username:
# from_secret: cache_server_user
# key:
# from_secret: cache_server_key
# path: /var/cache/drone
# restore: true
# mount:
# - node_modules
type: kubernetes
name: build
# ============ BUILD STEPS ===============
- name: build-prod
image: glmdev/node-pnpm:latest
metadata:
labels:
pod-security.kubernetes.io/audit: privileged
services:
- name: docker daemon
image: docker:dind
privileged: true
environment:
DOCKER_TLS_CERTDIR: ""
# when:
# event:
# - tag
# - promote
steps:
- name: node.js build
image: node:18
commands:
- pnpm i --silent
- npm add --global pnpm
- pnpm i
- rm -f ./node_modules/ngx-monaco-editor/lib/monaco.d.ts
- sed -i '1d' ./node_modules/ngx-monaco-editor/lib/types.d.ts
- ./node_modules/.bin/ionic build --prod
- ./node_modules/.bin/ngsw-config ./www/ ./ngsw-config.json /i
- tar czf build.tar.gz www
- echo -n $(uuidgen) | tee ./www/version.html
# =============== REBULD CACHE ==============
# - name: rebuild node_modules cache
# image: appleboy/drone-sftp-cache
# settings:
# server:
# from_secret: cache_server
# port: 22
# username:
# from_secret: cache_server_user
# key:
# from_secret: cache_server_key
# path: /var/cache/drone
# rebuild: true
# mount:
# - node_modules
# =============== RELEASE ===============
- name: release
image: plugins/gitea-release
settings:
api_key:
from_secret: gitea_api_key
base_url: https://code.garrettmills.dev
files: build.tar.gz
title: ${DRONE_TAG}
when:
event: tag
# =============== DEPLOY TO DEV SITE ===============
- name: copy artifacts to staging site
image: appleboy/drone-scp
settings:
host:
from_secret: dev_site_host
username:
from_secret: dev_site_user
key:
from_secret: dev_site_key
port: 22
source: build.tar.gz
target: /etc/glmdev/noded
when:
event: promote
target: staging
- name: deploy artifacts on staging site
image: appleboy/drone-ssh
settings:
host:
from_secret: dev_site_host
username:
from_secret: dev_site_user
key:
from_secret: dev_site_key
port: 22
script:
- cd /etc/glmdev/noded
- rm -rf www
- tar xzf build.tar.gz
- cd www
- echo -n "$(uuidgen)" | sudo tee version.html
when:
event: promote
target: staging
# =============== DEPLOY TO PROD SITE ===============
- name: copy artifacts to production site
image: appleboy/drone-scp
settings:
host:
from_secret: prod_site_host
username:
from_secret: prod_site_user
key:
from_secret: prod_site_key
port: 22
source: build.tar.gz
target: /etc/glmdev/noded-prod
when:
event: promote
target: production
- name: deploy artifacts on production site
image: appleboy/drone-ssh
settings:
host:
from_secret: prod_site_host
username:
from_secret: prod_site_user
key:
from_secret: prod_site_key
port: 22
script:
- cd /etc/glmdev/noded-prod
- rm -rf www
- tar xzf build.tar.gz
- cd www
- echo -n "$(uuidgen)" | sudo tee version.html
when:
event: promote
target: production
# =============== BUILD NOTIFICATIONS ===============
- name: send build success notifications
image: plugins/webhook
settings:
urls:
from_secret: notify_webhook_url
content_type: application/json
template: |
{
"title": "Drone-CI [noded-frontend @ ${DRONE_BUILD_NUMBER}]",
"message": "Build completed successfully. (Changes by ${DRONE_COMMIT_AUTHOR})",
"priority": 4
}
when:
status: success
event:
exclude:
- promote
- name: send build error notifications
image: plugins/webhook
settings:
urls:
from_secret: notify_webhook_url
content_type: application/json
template: |
{
"title": "Drone-CI [noded-frontend @ ${DRONE_BUILD_NUMBER}]",
"message": "Build failed! (Changes by ${DRONE_COMMIT_AUTHOR})",
"priority": 6
}
when:
status: failure
event:
exclude:
- promote
# =============== DEPLOY NOTIFICATIONS ===============
- name: send deploy success notifications
image: plugins/webhook
settings:
urls:
from_secret: notify_webhook_url
content_type: application/json
template: |
{
"title": "Drone-Deploy [noded-frontend @ ${DRONE_BUILD_NUMBER} to ${DRONE_DEPLOY_TO}]",
"message": "Deployment completed successfully. (Changes by ${DRONE_COMMIT_AUTHOR})",
"priority": 4
}
when:
status: success
event:
- promote
- name: send deploy error notifications
image: plugins/webhook
settings:
urls:
from_secret: notify_webhook_url
content_type: application/json
template: |
{
"title": "Drone-Deploy [noded-frontend @ ${DRONE_BUILD_NUMBER} to ${DRONE_DEPLOY_TO}]",
"message": "Deployment failed! (Changes by ${DRONE_COMMIT_AUTHOR})",
"priority": 6
}
when:
status: failure
event:
- promote
- name: container build
image: docker:latest
privileged: true
commands:
- "while ! docker stats --no-stream; do sleep 1; done"
- docker image build -t $DOCKER_REGISTRY/noded/frontend .
- docker push $DOCKER_REGISTRY/noded/frontend
environment:
DOCKER_HOST: tcp://localhost:2375
DOCKER_REGISTRY:
from_secret: DOCKER_REGISTRY
# when:
# event:
# - tag
# - promote

File diff suppressed because it is too large Load Diff