2018-10-13 10:03:14 +00:00
|
|
|
image: node:alpine # Use latest version of Node.js on Alpine
|
2016-02-29 14:25:06 +00:00
|
|
|
|
2018-10-28 08:16:18 +00:00
|
|
|
cache: # add cache to 'node_modules' for speeding up builds
|
|
|
|
paths:
|
|
|
|
- node_modules/ # Node modules and dependencies
|
|
|
|
|
|
|
|
test:
|
2020-04-15 02:38:39 +00:00
|
|
|
before_script:
|
|
|
|
- 'which ssh-agent || (apk update && apk add openssh-client git)'
|
2020-05-15 10:34:26 +00:00
|
|
|
- npm install --only=prod
|
2020-04-15 02:38:39 +00:00
|
|
|
|
2018-09-25 00:16:25 +00:00
|
|
|
script:
|
2019-08-23 02:32:37 +00:00
|
|
|
- npm install --only=prod snyk && npm run snyk # Refer to "scripts" in package.json
|
2018-11-03 03:58:26 +00:00
|
|
|
- npm run hexo
|
2018-10-28 08:16:18 +00:00
|
|
|
|
2020-04-15 02:38:39 +00:00
|
|
|
# Update github mirror
|
|
|
|
after_script:
|
|
|
|
# Import SSH key
|
|
|
|
- eval $(ssh-agent -s)
|
|
|
|
- echo "$GH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- chmod 700 ~/.ssh
|
|
|
|
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
|
|
|
- chmod 644 ~/.ssh/known_hosts
|
|
|
|
|
|
|
|
# (workaround) force exit code 0
|
|
|
|
- ssh -T git@github.com || ":"
|
|
|
|
- git remote add mirror git@github.com:curbengh/blog.git
|
2020-04-15 03:56:53 +00:00
|
|
|
# Discard changes before checking out branch
|
|
|
|
- git reset HEAD --hard
|
2020-04-15 03:46:48 +00:00
|
|
|
- git checkout master && git push mirror master
|
|
|
|
- git checkout site && git push mirror site
|
2020-04-15 02:38:39 +00:00
|
|
|
|
2019-12-23 23:36:51 +00:00
|
|
|
rules:
|
|
|
|
# Skip in renovate job
|
|
|
|
- if: '$RENOVATE == "true"'
|
|
|
|
when: never
|
|
|
|
# Only trigger through push event in master branch
|
|
|
|
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "push"'
|
|
|
|
when: always
|
|
|
|
# Only trigger through "Run pipeline" in master branch
|
|
|
|
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "web"'
|
|
|
|
when: always
|
2018-11-06 08:37:35 +00:00
|
|
|
|
2018-10-28 08:16:18 +00:00
|
|
|
renovate: # Check dependency update
|
2020-05-15 10:34:26 +00:00
|
|
|
before_script:
|
|
|
|
- npm install --only=prod
|
|
|
|
|
2018-10-28 08:16:18 +00:00
|
|
|
script:
|
2019-08-23 02:32:37 +00:00
|
|
|
- npm install --only=prod renovate
|
2018-10-28 07:28:45 +00:00
|
|
|
- npm run renovate
|
2018-09-29 06:03:51 +00:00
|
|
|
|
2019-12-23 23:36:51 +00:00
|
|
|
rules:
|
|
|
|
# Only trigger when environment variable matches and through schedule in master branch
|
|
|
|
- if: '$RENOVATE == "true" && $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule"'
|
|
|
|
when: always
|
|
|
|
# Only trigger when environment variable matches and through "Run pipeline" in master branch
|
|
|
|
- if: '$RENOVATE == "true" && $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "web"'
|
|
|
|
when: always
|
2018-10-01 03:05:37 +00:00
|
|
|
|
2018-10-02 04:35:40 +00:00
|
|
|
# # Uncomment below (and comment/remove above) lines for gitlab pages
|
|
|
|
# image: node:latest # Use latest version of Node.js
|
2018-10-01 03:05:37 +00:00
|
|
|
# pages:
|
|
|
|
# cache: # add cache to 'node_modules' for speeding up builds
|
|
|
|
# paths:
|
|
|
|
# - node_modules/ # Node modules and dependencies
|
|
|
|
|
|
|
|
# script:
|
|
|
|
# - npm install -g snyk hexo-cli
|
|
|
|
# - npm install # install node modules
|
|
|
|
# - snyk auth $SNYK_TOKEN
|
|
|
|
# - snyk protect # Apply patches to node modules
|
|
|
|
# - snyk test # Check node modules for vulnerability
|
|
|
|
# - hexo deploy # deploy the site.
|
|
|
|
|
|
|
|
# artifacts:
|
|
|
|
# paths:
|
|
|
|
# - public # deploy to the 'public' folder.
|
|
|
|
|
|
|
|
# only:
|
|
|
|
# - master # this job will affect only the 'master' branch
|