ci:doc: Rewrite script to import doc on fdo ensuring the right job is used

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/999>
This commit is contained in:
Thibault Saunier 2021-09-30 12:47:20 -03:00 committed by GStreamer Marge Bot
parent b6112ca6f9
commit 9270f072cc
2 changed files with 39 additions and 36 deletions

View file

@ -0,0 +1,39 @@
#!/usr/bin/python3
import os
import gitlab
from datetime import datetime
import tempfile
from subprocess import check_call, call, check_output
BRANCH="main"
NAMESPACE="gstreamer"
JOB="documentation"
DOC_BASE="/srv/gstreamer.freedesktop.org/public_html/documentation"
print(f"Running at {datetime.now()}")
with tempfile.TemporaryDirectory() as tmpdir:
os.chdir(tmpdir)
gl = gitlab.Gitlab("https://gitlab.freedesktop.org/")
project = gl.projects.get(1357)
pipelines = project.pipelines.list()
for pipeline in pipelines:
if pipeline.ref != BRANCH:
continue
job, = [j for j in pipeline.jobs.list() if j.name == "documentation"]
if job.status != "success":
continue
url = f"https://gitlab.freedesktop.org/gstreamer/gstreamer/-/jobs/{job.id}/artifacts/download"
print("============================================================================================================================")
print(f"Updating documentation from: {url}\n\n")
check_call(f"wget {url} -O gstdocs.zip", shell=True)
print("Unziping file.")
check_output("unzip gstdocs.zip", shell=True)
print("Running rsync.")
call(f"rsync -rvaz --links --delete documentation/ {DOC_BASE}", shell=True)
call(f"chmod -R g+w {DOC_BASE}; chgrp -R gstreamer {DOC_BASE}", shell=True)
print(f"Done updating doc")
break

View file

@ -1,36 +0,0 @@
#!/bin/sh
set -e
BRANCH=main
NAMESPACE=gstreamer
JOB=documentation
WORK_DIR=$(mktemp -d -p "$DIR")
# deletes the temp directory
cleanup() {
rm -rf "$WORK_DIR"
echo "Deleted temp working directory $WORK_DIR"
}
# register the cleanup function to be called on the EXIT signal
trap cleanup EXIT
echo ""
echo "============================================================================================================================"
echo "Updating documentation from: https://gitlab.freedesktop.org/$NAMESPACE/gstreamer/-/jobs/artifacts/$BRANCH/download?job=$JOB"
date
cd $WORK_DIR
wget https://gitlab.freedesktop.org/$NAMESPACE/gstreamer/-/jobs/artifacts/$BRANCH/download?job=$JOB -O gstdocs.zip
unzip gstdocs.zip
DOC_BASE="/srv/gstreamer.freedesktop.org/public_html/documentation"
rsync -rvaz --links --delete documentation/ $DOC_BASE || /bin/true
chmod -R g+w $DOC_BASE; chgrp -R gstreamer $DOC_BASE
echo "Done updating documentation"
echo ""