-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
91 lines (82 loc) · 3.1 KB
/
.gitlab-ci.yml
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
### Global CI/CD Settings ###
stages:
- worker-build
- worker-test
- cron
- website-test
variables:
GIT_STRATEGY: clone
GIT_DEPTH: "50" # this is the default value
REGISTRY: "https://code.ornl.gov:4567/rse-public/ornl-software-catalog"
WORKER_URL: "${REGISTRY}/worker"
include:
remote: "https://code.ornl.gov/rse-deployment/rse-sharables/-/raw/master/.gitlab-ci-before_script.yml"
after_script:
- sudo chown -R gitlab-runner .
### CI/CD Jobs ###
#worker_build_job:
#stage: worker-build
#script:
#- func_rse_docker_cleanup
#- docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
#- docker build -f worker.Dockerfile -t $WORKER_URL/$CI_COMMIT_REF_NAME .
#- docker push $WORKER_URL/$CI_COMMIT_REF_NAME
#tags:
#- rse-multi-builder
#rules:
#- changes:
#- _explore/scripts/requirements.txt
#worker_test_job:
#stage: worker-test
#script:
#- func_rse_docker_cleanup
#- docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
#- docker pull $WORKER_URL/$CI_COMMIT_REF_NAME
#- docker run --name ornl-software-catalog -v $PWD:/app bash -c "make test"
#tags:
#- rse-multi-builder
#rules:
#- changes:
#- _explore/scripts/*.py
scheduled-data-update:
rules:
- if: $CI_PIPELINE_SOURCE == 'schedule'
stage: cron
tags:
- software-catalog
before_script:
- git remote set-url origin "https://oauth2:${PROJECT_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
- git config user.name "${GITLAB_USER_NAME}"
- git config user.email "${GITLAB_USER_EMAIL}"
- git config push.default simple
script:
- ./_explore/scripts/cron.sh --docker
# NOTE: this job just tests that a feature branch with a MR out can still work on dev
pages:
stage: website-test
variables:
# this image is based off of the "jekyll/builder" image from https://github.com/envygeeks/jekyll-docker
# we use this image instead of pulling from Docker Hub, to avoid rate limits
DOCKER_IMAGE: "code.ornl.gov:4567/rse-public/ornl-software-catalog/jekyll/builder:latest"
DOCKER_WORKDIR: /srv/jekyll # default workdir of image, plus where we mount the repository to
IMAGE_NAME: software-catalog-website
script:
- func_rse_docker_cleanup
- docker login --username=$CI_REGISTRY_USER --password=$CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $DOCKER_IMAGE
- docker run -dit --name $IMAGE_NAME -v $PWD:$DOCKER_WORKDIR -e JEKYLL_ROOTLESS=true -e JEKYLL_ENV=production $DOCKER_IMAGE bash
# update bundler to match Gemfile.lock "BUNDLED WITH" version
- docker exec -i $IMAGE_NAME bash -c "gem install bundler:$(tail -1 Gemfile.lock | xargs) && jekyll build -d public"
# for Gitlab Pages, you must have the built artifacts in the "public" directory
artifacts:
paths:
- public
tags:
- rse-multi-builder
rules:
# test that the website can build on any feature/hotfix branch.
- if: |
$CI_PIPELINE_SOURCE == 'merge_request_event'
&& $CI_COMMIT_BRANCH != 'dev'
&& $CI_COMMIT_BRANCH != 'master'
&& $CI_COMMIT_BRANCH != 'main'