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
Commit 82f60405 authored by Simon Desnoe's avatar Simon Desnoe Committed by Dorian Turba
Browse files

refactor: use python_install for depandabot

parent 73b77af1
No related branches found
No related tags found
1 merge request!1feat: add depandabot template
depandabot:
stage: dependency_management
image: python:${IMAGE_TAG}
variables:
PROJECT_PATH: "."
REQUIREMENTS_FILE_PATH: "${PROJECT_PATH}/requirements.txt"
IMAGE_TAG: "latest"
GITLAB_API_URL: "${CI_SERVER_HOST}"
include:
- remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/r2_metadata/python_install@latest.yaml'
before_script:
- python --version ; pip --version # debugging
- python -m venv venv --upgrade-deps || python -m venv venv
- source venv/bin/activate
- pip install pip-tools
depandabot:
extends:
- .python_install
stage: build
image: python:${IMAGE_TAG}
script:
- DEPS_BRANCH="depandabot/requirements-txt/$(date +%s)"
- |
COMMIT_MESSAGE="build(deps): bump new versions"
- $([ -f ${REQUIREMENTS_FILE_PATH} ]) && ACTION="update" || ACTION="create"
- pip-compile --quiet -o ${REQUIREMENTS_FILE_PATH}
- if [ -n "$(git status --porcelain ${REQUIREMENTS_FILE_PATH})" ]; then
- |
curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \
--form "branch=$DEPS_BRANCH" \
--form "ref=${CI_DEFAULT_BRANCH}" \
"https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/repository/branches"
- |
curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \
--form "branch=$DEPS_BRANCH" \
--form "commit_message=$COMMIT_MESSAGE" \
--form "actions[][action]=$ACTION" \
--form "actions[][file_path]=${REQUIREMENTS_FILE_PATH}" \
--form "actions[][content]=<${REQUIREMENTS_FILE_PATH}" \
"https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/repository/commits"
- |
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
variables:
PYTHON_SETUP: pip install pip-tools
GITLAB_API_URL: "${CI_SERVER_HOST}"
script:
- !reference [.python_install, script]
- DEPS_BRANCH="depandabot/requirements-txt/$(date +%s)"
- |
COMMIT_MESSAGE="build(deps): bump new versions"
- $([ -f ${REQUIREMENTS_FILE_PATH} ]) && ACTION="update" || ACTION="create"
- pip-compile --quiet -o ${REQUIREMENTS_FILE_PATH}
- if [ -n "$(git status --porcelain ${REQUIREMENTS_FILE_PATH})" ]; then
- |
curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \
--form "branch=$DEPS_BRANCH" \
--form "ref=${CI_DEFAULT_BRANCH}" \
"https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/repository/branches"
- |
curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \
--form "branch=$DEPS_BRANCH" \
--form "commit_message=$COMMIT_MESSAGE" \
--form "actions[][action]=$ACTION" \
--form "actions[][file_path]=${REQUIREMENTS_FILE_PATH}" \
--form "actions[][content]=<${REQUIREMENTS_FILE_PATH}" \
"https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/repository/commits"
- |
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
......
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