Skip to content
Snippets Groups Projects
Commit a3b0414a authored by Kwangjin Lee's avatar Kwangjin Lee
Browse files

Update .gitlab-ci.yml file

parent 5aad94b9
No related branches found
No related tags found
No related merge requests found
Pipeline #260075 failed
image: alpine:latest
image: python:3.9
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.pip-cache"
WEBHOOK_URL: "https://mude.citg.tudelft.nl/hooks"
WEBHOOK_TOKEN: "glpat-Lohnt8MN6nWzpcwyhprL"
GIT_STRATEGY: clone
cache:
paths:
- .pip-cache/
stages:
- setup
- sync
- update_repo
- deploy
before_script:
- apk add --no-cache curl
setup:
stage: setup
script:
- apt-get update && apt-get install -y curl git
- pip install jupytext nbconvert
artifacts:
paths:
- .pip-cache/
deploy-draft-students:
stage: deploy
sync_notebooks:
stage: sync
script:
- mkdir -p synced_files
- |
curl -X POST https://mude.citg.tudelft.nl/hooks/files-sync-students-draft \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-Lohnt8MN6nWzpcwyhprL" \
-d '{
"object_kind": "pipeline",
"object_attributes": {
"status": "success",
"ref": "main"
}
}'
rules:
- if: $CI_COMMIT_BRANCH == "main"
changes:
- src/students/**/*
when: always
for notebook in $(find ./src -name "*.ipynb"); do
relative_path=${notebook#./src/}
synced_dir="synced_files/$(dirname $relative_path)"
mkdir -p "$synced_dir"
# Convert to various formats
jupytext --to notebook "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).ipynb"
jupytext --to markdown "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).md"
jupytext --to py:percent "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).py"
# Strip outputs from the notebook
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to notebook --inplace "${synced_dir}/$(basename $notebook)"
done
artifacts:
paths:
- synced_files/
deploy-teachers:
stage: deploy
update_repo:
stage: update_repo
script:
- git config user.name "GitLab CI"
- git config user.email "gitlab-ci@example.com"
- git add synced_files/
- |
curl -X POST https://mude.citg.tudelft.nl/hooks/files-sync-teachers \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-Lohnt8MN6nWzpcwyhprL" \
-d '{
"object_kind": "pipeline",
"object_attributes": {
"status": "success",
"ref": "main"
}
}'
rules:
- if: $CI_COMMIT_BRANCH == "main"
changes:
- src/teachers/**/*
when: always
if [ -n "$(git status --porcelain)" ]; then
git commit -m "Update synced files [skip ci]"
git push "https://oauth2:${GIT_PUSH_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git" HEAD:$CI_COMMIT_REF_NAME
else
echo "No changes to commit"
fi
deploy-production-students:
deploy:
stage: deploy
script:
- |
curl -X POST https://mude.citg.tudelft.nl/hooks/files-sync-students \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-Lohnt8MN6nWzpcwyhprL" \
-d '{
"object_kind": "pipeline",
"object_attributes": {
"status": "success",
"ref": "release"
}
}'
for webhook in "files-sync-students-draft" "files-sync-teachers" "files-sync-students"; do
curl -X POST "${WEBHOOK_URL}/${webhook}" \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: ${WEBHOOK_TOKEN}" \
-d '{
"object_kind": "pipeline",
"object_attributes": {
"status": "success",
"ref": "'"$CI_COMMIT_REF_NAME"'"
}
}'
done
rules:
- if: $CI_COMMIT_BRANCH == "release"
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "release"
changes:
- src/students/**/*
- src/**/*
when: always
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment