mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
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:
parent
b6112ca6f9
commit
9270f072cc
2 changed files with 39 additions and 36 deletions
39
ci/gitlab/freedesktop_doc_importer.py
Executable file
39
ci/gitlab/freedesktop_doc_importer.py
Executable 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
|
|
@ -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 ""
|
Loading…
Reference in a new issue