blog/.gitlab-ci.yml

103 lines
2.4 KiB
YAML
Raw Normal View History

image: node:alpine # Use latest version of Node.js on Alpine
2016-02-29 14:25:06 +00:00
2023-10-02 00:58:34 +00:00
cache:
paths:
2023-10-02 00:58:34 +00:00
- node_modules/
variables:
NODE_ENV: "production"
2023-10-02 00:58:34 +00:00
# Rename to 'pages' for gitlab pages
build:
stage: build
2020-04-15 02:38:39 +00:00
before_script:
- apk update && apk add git
2020-08-10 04:11:10 +00:00
- npm install
2020-04-15 02:38:39 +00:00
script:
2023-10-02 00:58:34 +00:00
# Generate site
- npm run build
2021-03-12 08:04:58 +00:00
rules:
# Only trigger through push & "Run pipeline" events not in "site" branch; Skip in renovate job
- if: '$RENOVATE != "true" && $CI_COMMIT_REF_NAME != "site" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
when: always
2021-03-15 22:47:39 +00:00
artifacts:
paths:
- public/
expire_in: 30 days
test:
stage: test
script:
2023-10-02 00:58:34 +00:00
# Homepage should exist and non-empty
- sh check-homepage.sh
rules:
- if: '$RENOVATE != "true" && $CI_COMMIT_REF_NAME == "master" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
when: always
2021-03-15 22:47:39 +00:00
artifacts:
paths:
- public/
expire_in: 30 days
deploy:
stage: deploy
before_script:
- apk update && apk add openssh-client rsync
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- echo "$SSH_KEY_1" > ~/.ssh/id_host_1
- chmod 600 ~/.ssh/id_host_1
- echo "$SSH_KEY_2" > ~/.ssh/id_host_2
- chmod 600 ~/.ssh/id_host_2
- echo "$SSH_CONFIG" > ~/.ssh/config
- chmod 600 ~/.ssh/config
script:
- rsync -azvh --delete public/ host-1:/var/www/
- rsync -azvh --delete public/ host-2:/var/www/
rules:
- if: '$RENOVATE != "true" && $CI_COMMIT_REF_NAME == "master" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
when: always
deploy_pages:
stage: deploy
trigger:
project: curben/curben.gitlab.io
branch: master
strategy: depend
rules:
- if: '$RENOVATE != "true" && $CI_COMMIT_REF_NAME == "master" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
when: always
2023-10-02 00:58:34 +00:00
# Check dependency update
renovate:
before_script:
- apk update && apk add git
- npm install
script:
- npm install snyk @snyk/protect && npm run snyk
2021-04-04 18:05:29 +00:00
- npm install renovate && npm run renovate
2021-03-15 22:47:39 +00:00
# No artifact
dependencies: []
rules:
- if: '$RENOVATE == "true" && $CI_COMMIT_REF_NAME == "master" && ($CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web")'
when: always
include:
- template: Security/Secret-Detection.gitlab-ci.yml