-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitlab-ci-seo.yml
More file actions
102 lines (99 loc) · 3.16 KB
/
.gitlab-ci-seo.yml
File metadata and controls
102 lines (99 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Seo is scheduled therefore make sure only basic seo build job and deployment is run
.seo-rules:
rules:
# don't run when triggered from other pipeline (deployment-only-pipeline)
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
# don't run when making a merge-request via gitlab
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
# run when pushed to main, staging or develop branch
- if: '$CI_COMMIT_REF_NAME =~ /^(main|staging|develop)$/'
# run when triggered from the gitlab ui to start a pipeline
- if: $CI_PIPELINE_SOURCE == "web"
when: on_success
build-seo:
stage: build
image: node:lts
environment: $CI_COMMIT_REF_NAME
rules:
# don't run when triggered from other pipeline (deployment-only-pipeline)
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
when: never
- when: on_success
needs:
# needs the artifact: config and environment variables
- install-node
- job: modify-env
artifacts: true
- verify-node-audit
script:
- npm ci --prefer-offline --no-audit --no-fund --loglevel=error --ignore-scripts
- cat .env.production
- npm run build-vike
# rename the dist/client output folder
- mv dist/client dist/seo
- rm -rf dist/seo/testdata
- rm -rf dist/seo/particles
- rm -f dist/seo/researchUnits.json
- rm -f dist/seo/packagelist.json
artifacts:
name: 'frontend seo build '
expire_in: 1 day
# stores the seo pre-rendered htmls
paths:
- dist/seo/
- dist/sitemap.xml
retry:
max: 2
schedule-seo-deployment:
stage: deploy
image: alpine:3.20
environment: $CI_COMMIT_REF_NAME
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: on_success
- when: never # only run when scheduled
needs:
# needs the artifact: config and environment variables
- modify-env
- verify-node-audit
- build-seo
variables:
GIT_STRATEGY: none
RCLONE_CONFIG_SWITCH_TYPE: 's3'
RCLONE_S3_PROVIDER: 'Other'
RCLONE_S3_ENV_AUTH: 'true'
before_script:
- apk add curl unzip --no-cache
- curl -O https://downloads.rclone.org/v1.59.0/rclone-v1.59.0-linux-amd64.zip
- unzip rclone-v1.59.0-linux-amd64.zip
- cp rclone-v1.59.0-linux-amd64/rclone /usr/bin/
- rm rclone-v1.59.0-linux-amd64.zip
- rm -rf rclone-v1.59.0-linux-amd64
- |
if [ "${CI_COMMIT_REF_NAME}" == "main" ]; then
BUCKET_NAME="frontend"
else
BUCKET_NAME="frontend-${CI_COMMIT_REF_NAME}"
fi
if [ "${CI_COMMIT_REF_NAME}" == "develop" ]; then
BUCKET_NAME="frontend-dev"
fi
echo "Target for rclone copy is the bucket: '${BUCKET_NAME}'"
script:
- echo "Check for the artifacts in the filesystem"
- ls -l
- ls dist/ -l
# - ls storybook/ -l
# copy all files from the dist folder into root
- cp -r dist/* ./
# - ls -l
# remove the dist folder recursively
- rm -rf dist
# use -q for quiet to not list all the files
- ls -l
- echo "going to rclone copy from ./ to switch:${BUCKET_NAME}"
- rclone copy ./sitemap.xml "switch:${BUCKET_NAME}" --verbose
- rclone sync ./seo/ "switch:${BUCKET_NAME}"/seo/ --verbose
retry:
max: 2