frontend/.drone.yml

199 lines
5.0 KiB
YAML
Raw Normal View History

2020-10-05 22:49:10 +00:00
kind: pipeline
name: default
2020-10-28 17:44:37 +00:00
type: docker
2020-10-05 22:49:10 +00:00
steps:
2020-10-28 17:44:37 +00:00
# ============ 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
2020-10-28 18:51:39 +00:00
path: /var/cache/drone
restore: true
mount:
- node_modules
2020-10-28 17:44:37 +00:00
2020-10-05 23:02:52 +00:00
# ============ BUILD STEPS ===============
2020-10-05 22:49:10 +00:00
- name: build-prod
image: node:14
commands:
- npm i
2020-10-05 22:52:50 +00:00
- ./node_modules/.bin/ionic build --prod
- ./node_modules/.bin/ngsw-config ./www/ ./ngsw-config.json /i
2020-10-05 22:49:10 +00:00
- tar czf build.tar.gz www
2020-10-05 23:02:52 +00:00
2020-10-28 17:44:37 +00:00
# =============== 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
2020-10-28 18:51:39 +00:00
path: /var/cache/drone
rebuild: true
mount:
- node_modules
2020-10-28 17:44:37 +00:00
2020-10-05 23:02:52 +00:00
# =============== RELEASE ===============
2020-10-05 22:49:10 +00:00
- 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
2020-10-05 23:02:52 +00:00
# =============== 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
2020-10-05 23:27:21 +00:00
- 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
2020-10-05 23:27:21 +00:00
when:
event: promote
target: staging
2020-10-05 23:02:52 +00:00
2020-10-06 00:46:28 +00:00
# =============== 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
2020-10-06 00:56:21 +00:00
target: production
2020-10-06 00:47:20 +00:00
- name: deploy artifacts on production site
2020-10-06 00:46:28 +00:00
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
2020-10-06 00:46:28 +00:00
when:
event: promote
target: production
2020-10-28 16:28:27 +00:00
# =============== BUILD NOTIFICATIONS ===============
- name: send build success notifications
2020-10-05 22:49:10 +00:00
image: plugins/webhook
settings:
urls:
from_secret: notify_webhook_url
content_type: application/json
template: |
{
2020-10-28 16:28:27 +00:00
"title": "Drone-CI [noded-frontend @ ${DRONE_BUILD_NUMBER}]",
"message": "Build completed successfully. (Changes by ${DRONE_COMMIT_AUTHOR})",
2020-10-05 22:49:10 +00:00
"priority": 4
}
when:
status: success
2020-10-28 16:28:27 +00:00
event:
exclude:
- promote
- name: send build error notifications
2020-10-05 22:49:10 +00:00
image: plugins/webhook
settings:
urls:
from_secret: notify_webhook_url
content_type: application/json
template: |
{
2020-10-28 16:28:27 +00:00
"title": "Drone-CI [noded-frontend @ ${DRONE_BUILD_NUMBER}]",
"message": "Build failed! (Changes by ${DRONE_COMMIT_AUTHOR})",
2020-10-05 22:49:10 +00:00
"priority": 6
}
when:
status: failure
2020-10-28 16:28:27 +00:00
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})",
2020-10-28 16:28:27 +00:00
"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})",
2020-10-28 16:28:27 +00:00
"priority": 6
}
when:
status: failure
event:
- promote