Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects

feat: add depandabot template

Merged Simon Desnoe requested to merge template-depandabot into main
All threads resolved!
1 file
+ 39
41
Compare changes
  • Side-by-side
  • Inline
depandabot:
include:
stage: dependency_management
- remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/r2_metadata/python_install@latest.yaml'
image: python:${IMAGE_TAG}
variables:
PROJECT_PATH: "."
REQUIREMENTS_FILE_PATH: "${PROJECT_PATH}/requirements.txt"
IMAGE_TAG: "latest"
GITLAB_API_URL: "${CI_SERVER_HOST}"
before_script:
depandabot:
- python --version ; pip --version # debugging
extends:
- python -m venv venv --upgrade-deps || python -m venv venv
- .python_install
- source venv/bin/activate
stage: build
- pip install pip-tools
image: python:${IMAGE_TAG}
script:
variables:
- DEPS_BRANCH="depandabot/requirements-txt/$(date +%s)"
PYTHON_SETUP: pip install pip-tools
- |
GITLAB_API_URL: "${CI_SERVER_HOST}"
COMMIT_MESSAGE="build(deps): bump new versions"
- $([ -f ${REQUIREMENTS_FILE_PATH} ]) && ACTION="update" || ACTION="create"
script:
- pip-compile --quiet -o ${REQUIREMENTS_FILE_PATH}
- !reference [.python_install, script]
- if [ -n "$(git status --porcelain ${REQUIREMENTS_FILE_PATH})" ]; then
- DEPS_BRANCH="depandabot/requirements-txt/$(date +%s)"
- |
- |
curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \
COMMIT_MESSAGE="build(deps): bump new versions"
--form "branch=$DEPS_BRANCH" \
- $([ -f ${REQUIREMENTS_FILE_PATH} ]) && ACTION="update" || ACTION="create"
--form "ref=${CI_DEFAULT_BRANCH}" \
- pip-compile --quiet -o ${REQUIREMENTS_FILE_PATH}
"https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/repository/branches"
- if [ -n "$(git status --porcelain ${REQUIREMENTS_FILE_PATH})" ]; then
- |
- |
curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \
curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \
--form "branch=$DEPS_BRANCH" \
--form "branch=$DEPS_BRANCH" \
--form "commit_message=$COMMIT_MESSAGE" \
--form "ref=${CI_DEFAULT_BRANCH}" \
--form "actions[][action]=$ACTION" \
"https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/repository/branches"
--form "actions[][file_path]=${REQUIREMENTS_FILE_PATH}" \
- |
--form "actions[][content]=<${REQUIREMENTS_FILE_PATH}" \
curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \
"https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/repository/commits"
--form "branch=$DEPS_BRANCH" \
- |
--form "commit_message=$COMMIT_MESSAGE" \
curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \
--form "actions[][action]=$ACTION" \
--form "source_branch=$DEPS_BRANCH" \
--form "actions[][file_path]=${REQUIREMENTS_FILE_PATH}" \
--form "target_branch=${CI_DEFAULT_BRANCH}" \
--form "actions[][content]=<${REQUIREMENTS_FILE_PATH}" \
--form "title=$COMMIT_MESSAGE" \
"https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/repository/commits"
"https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/merge_requests"
- |
- fi
curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \
 
--form "source_branch=$DEPS_BRANCH" \
 
--form "target_branch=${CI_DEFAULT_BRANCH}" \
 
--form "title=$COMMIT_MESSAGE" \
 
"https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/merge_requests"
 
- fi
Loading