2018-09-19 11:31:50 +00:00
|
|
|
# Use latest version of Node.js
|
2018-09-18 09:31:05 +00:00
|
|
|
image: node:latest
|
2016-02-29 14:25:06 +00:00
|
|
|
|
2018-09-25 00:16:25 +00:00
|
|
|
stages:
|
|
|
|
- test
|
|
|
|
- deploy
|
2018-09-19 11:31:50 +00:00
|
|
|
|
2018-09-25 00:16:25 +00:00
|
|
|
cache: # add cache to 'node_modules' for speeding up builds
|
|
|
|
paths:
|
|
|
|
- node_modules/ # Node modules and dependencies
|
2016-02-29 14:25:06 +00:00
|
|
|
|
2018-09-25 01:14:40 +00:00
|
|
|
before_script: # install tools before jobs
|
|
|
|
- npm install -g hexo-cli snyk
|
|
|
|
- snyk auth $SNYK_TOKEN
|
2018-09-25 00:16:25 +00:00
|
|
|
|
|
|
|
snyk-test:
|
|
|
|
stage: test
|
|
|
|
script:
|
2018-09-25 01:14:40 +00:00
|
|
|
- npm install # install node modules
|
|
|
|
- snyk protect # Apply patches to node modules
|
|
|
|
- snyk test # Verify node modules for vulnerability
|
2018-09-25 00:57:38 +00:00
|
|
|
only:
|
|
|
|
- master
|
2018-09-25 00:16:25 +00:00
|
|
|
|
|
|
|
pages:
|
|
|
|
stage: deploy
|
|
|
|
script:
|
2018-09-19 11:31:50 +00:00
|
|
|
- hexo deploy # deploy the site
|
|
|
|
- find public -type f -iregex '.*\.\(htm\|html\|txt\|text\|js\|css\)$' -execdir gzip -f --keep {} \; # Compress files
|
2016-02-29 14:25:06 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
2018-09-19 11:31:50 +00:00
|
|
|
- public # deploy to the 'public' folder
|
2018-09-25 00:57:38 +00:00
|
|
|
only:
|
|
|
|
- master
|
2018-09-25 00:16:25 +00:00
|
|
|
when: on_success
|