mirror of https://gitlab.com/curben/blog
ci: after_script should only be used for cleanup
- in case of job failure
This commit is contained in:
parent
28c702670f
commit
1417d7d408
|
@ -8,31 +8,16 @@ variables:
|
||||||
NODE_ENV: "production"
|
NODE_ENV: "production"
|
||||||
|
|
||||||
## Rename to 'pages' for gitlab pages
|
## Rename to 'pages' for gitlab pages
|
||||||
test:
|
build:
|
||||||
stage: test
|
stage: build
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- apk update && apk add openssh-client git rsync
|
- apk update && apk add git
|
||||||
- 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
|
|
||||||
- npm install
|
- npm install
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- npm install snyk && npm run snyk # Refer to "scripts" in package.json
|
- npm install snyk && npm run snyk # Refer to "scripts" in package.json
|
||||||
- npm run build # Generate site
|
- npm run build # Generate site
|
||||||
- sh check-homepage.sh # Homepage should exists and non-empty
|
|
||||||
|
|
||||||
after_script:
|
|
||||||
- rsync -azvh --delete public/ host-1:/var/www/
|
|
||||||
- rsync -azvh --delete public/ host-2:/var/www/
|
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
# Only trigger through push & "Run pipeline" events in master branch; Skip in renovate job
|
# Only trigger through push & "Run pipeline" events in master branch; Skip in renovate job
|
||||||
|
@ -44,8 +29,36 @@ test:
|
||||||
# paths:
|
# paths:
|
||||||
# - public # deploy from the 'public' folder.
|
# - public # deploy from the 'public' folder.
|
||||||
|
|
||||||
deploy: # Trigger deploy job on curben/curben.gitlab.io
|
test:
|
||||||
|
stage: test
|
||||||
|
|
||||||
|
script:
|
||||||
|
- sh check-homepage.sh # Homepage should exists and non-empty
|
||||||
|
|
||||||
|
rules:
|
||||||
|
- if: '$RENOVATE != "true" && $CI_COMMIT_REF_NAME == "master" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
|
||||||
|
when: always
|
||||||
|
|
||||||
|
deploy:
|
||||||
stage: 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/
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
project: curben/curben.gitlab.io
|
project: curben/curben.gitlab.io
|
||||||
branch: master
|
branch: master
|
||||||
|
|
|
@ -125,6 +125,18 @@ ssh-keyscan -p 1234 x.x.x.x
|
||||||
```
|
```
|
||||||
|
|
||||||
``` yml .gitlab-ci.yml
|
``` yml .gitlab-ci.yml
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install
|
||||||
|
|
||||||
|
script:
|
||||||
|
- npm run build
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
stage: deploy
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- apk update && apk add openssh-client rsync
|
- apk update && apk add openssh-client rsync
|
||||||
- mkdir -p ~/.ssh
|
- mkdir -p ~/.ssh
|
||||||
|
@ -136,12 +148,8 @@ ssh-keyscan -p 1234 x.x.x.x
|
||||||
- chmod 600 ~/.ssh/id_remote_rsync
|
- chmod 600 ~/.ssh/id_remote_rsync
|
||||||
- echo "$SSH_CONFIG" > ~/.ssh/config
|
- echo "$SSH_CONFIG" > ~/.ssh/config
|
||||||
- chmod 600 ~/.ssh/config
|
- chmod 600 ~/.ssh/config
|
||||||
- npm install
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- hexo generate # Or `npm run build`
|
|
||||||
|
|
||||||
after_script:
|
|
||||||
## Dry run
|
## Dry run
|
||||||
- rsync -azvh --delete --dry-run public/ rsync-remote:/var/www/
|
- rsync -azvh --delete --dry-run public/ rsync-remote:/var/www/
|
||||||
## Remove above & uncomment below if no issue
|
## Remove above & uncomment below if no issue
|
||||||
|
|
Loading…
Reference in New Issue