1
0
Fork 0

ci(ant.k8s.vxm.cz): use python to commit instead of curl

This commit is contained in:
Vojtěch Mareš 2022-01-03 19:38:08 +01:00
parent c794f92967
commit 6a48c8c761
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
2 changed files with 33 additions and 7 deletions

View file

@ -19,11 +19,12 @@ build:
deploy:
stage: deploy
image: sikalabs/ci
variables:
GIT_STRATEGY: none
environment:
name: production
url: https://ant.k8s.vxm.cz
image: python:latest
before_script:
- python --version
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
script:
- 'curl --request PUT --header "PRIVATE-TOKEN: ${CI_PUSH_TOKEN}" --header "Content-Type: application/json" --data "{"branch": "main", "author_email": "ci@gitlab.mareshq.com", "author_name": "GitLab CI [bot]", "content": "image: ${IMAGE}:${IMAGE_TAG}", "commit_message": "[auto] build(signpost): update image to $IMAGE:$IMAGE_TAG"}" "https://gitlab.mareshq.com/api/v4/projects/60/repository/files/signpost%2Fvalues%2Eyaml"'
- pip install requests
- python ci/gitlab-commit.py

View file

@ -0,0 +1,25 @@
#!/usr/bin/env python3
import requests
import os
# import sys
pushToken = os.getenv("CI_PUSH_TOKEN")
image = os.getenv("IMAGE")
imageTag = os.getenv("IMAGE_TAG")
r = requests.put(
"https://gitlab.mareshq.com/api/v4/projects/60/repository/files/signpost%2Fvalues%2Eyaml",
data={
"branch": "main",
"author_email": "ci@gitlab.mareshq.com",
"author_name": "GitLab CI [bot]",
"content": f"image: {image}:{imageTag}",
"commit_message": f"[auto] build(signpost): update image to {image}:{imageTag}"
},
headers={
"PRIVATE-TOKEN": pushToken
}
)
print(r.status_code, r.reason)