1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00

Add hub's support for github PR

This commit is contained in:
Jean-Baptiste Holcroft 2017-10-04 10:46:26 +02:00
parent bf399e8193
commit 98d3086b33
7 changed files with 79 additions and 9 deletions

View file

@ -8,10 +8,7 @@ An admin user is created at installation, the login is what you provided at inst
# Github
Pulling works fine. But pushing still needs some love. Please read [Weblate's documentation about this](https://docs.weblate.org/en/latest/vcs.html).
I understant we need to manually install [hub](https://github.com/github/hub), a tool that creates pull-requests.
Which will require to download and install a binary file, as Debian 8 don't have Go>=1.8
You'll need to give weblate a github user and a token. Please read [github's documentation about token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/).
## Weblate and databases
@ -21,4 +18,4 @@ Carefull, this application install PostgreSQL and change the default configurati
## LDAP connexion
It doesn't work yet, but while [it looks doable](https://docs.weblate.org/en/latest/admin/auth.html?highlight=LDAP#ldap-authentication), I'm unsure it is a good idea to link this kind of tools to you LDAP.
It doesn't work yet, but while [it looks doable](https://docs.weblate.org/en/latest/admin/auth.html?highlight=LDAP#ldap-authentication), I'm unsure it is a good idea to connect this kind of tools to your LDAP.

View file

@ -9,6 +9,8 @@
path="/path" (PATH)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
github_account="myaccount"
github_token="myoauthtoken"
password="pass"
; Checks
pkg_linter=1

4
conf/hub_config Normal file
View file

@ -0,0 +1,4 @@
github.com:
- user: __GITHUBUSER__
oauth_token: __GITHUBTOKEN__
protocol: https

View file

@ -53,6 +53,22 @@
"en": "Choose an admin user for Weblate"
},
"example": "simon"
},
{
"name": "github_account",
"type": "text",
"ask": {
"en": "Github's username"
},
"example": "simon"
},
{
"name": "github_token",
"type": "text",
"ask": {
"en": "Github's token (oauth)"
},
"example": "simon"
}
]
}

View file

@ -24,6 +24,8 @@ domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
github_account=$YNH_APP_ARG_GITHUB_ACCOUNT
github_token=$YNH_APP_ARG_GITHUB_TOKEN
# This is a multi-instance app, meaning it can be installed several times independently
# The id of the app as stated in the manifest is available as $YNH_APP_ID
@ -63,6 +65,8 @@ ynh_app_setting_set "$app" path "$path_url"
ynh_app_setting_set "$app" admin "$admin"
ynh_app_setting_set "$app" is_public "$is_public"
ynh_app_setting_set "$app" final_path "$final_path"
ynh_app_setting_set "$app" github_account "$github_account"
ynh_app_setting_set "$app" github_token "$github_token"
#=================================================
# STANDARD MODIFICATIONS
@ -102,9 +106,49 @@ ynh_add_nginx_config
# CREATE DEDICATED USER
#=================================================
# Create system user for email notifications
# Hub needs a home directory with a config file
smtp_pwd=$(ynh_string_random)
ynh_system_user_create "$app" "/home/$app"
ynh_system_user_create "$app" "$final_path"
# Allow bash for our user, so he can use Hub
chsh --shell /bin/bash "$app"
#=================================================
# Download and install hub
#=================================================
arch=$(dpkg --print-architecture)
version="hub-linux-${arch}-2.3.0-pre10"
file_bin="hub-linux-${arch}-2.3.0-pre10.tgz"
wget --quiet "https://github.com/github/hub/releases/download/v2.3.0-pre10/${file_bin}"
case "$arch" in
"386")
sha256sum="08e29a118577b57f962c7c6e4c2e4bfc72b23df1469f2339631c55454893e24f"
;;
"amd64")
sha256sum="015297eb81e8fe11f3989d8f65c213111e508cecf0e9de8af1b7741de2077320"
;;
"arm")
sha256sum="a05cd6a42c973177c2a0b457451e9eef0035be67c666e4beebe3b9ed6d526f3d"
;;
"arm64")
sha256sum="6d845601196ef26342b8bafa9ab6e98c88270fb6dad60e0915396ba5486d0c76"
;;
*)
sha256sum="-1"
;;
esac
[[ $(sha256sum "$file_bin" | cut -d' ' -f1) = $sha256sum ]] || ynh_die "Hub's sha256sum failed (arch: ${arch})"
tar --extract --file "$file_bin" "$version/bin/hub"
mkdir "$final_path/bin/"
mv "$version/bin/hub" "$final_path/bin/"
mkdir "$final_path/.config/"
cp ../conf/hub_config "$final_path/.config/hub"
ynh_replace_string "__GITHUBUSER__" "$github_account" "$final_path/.config/hub"
ynh_replace_string "__GITHUBTOKEN__" "$github_token" "$final_path/.config/hub"
#=================================================
# SPECIFIC SETUP
@ -136,7 +180,9 @@ virtualenv "${final_path}/venv"
set +eu
source "${final_path}/venv/bin/activate"
"${final_path}/venv/bin/pip" install Weblate==2.16
"${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 django_sendmail_backend python-memcached
"${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached
# specific to YunoHost package:
"${final_path}/venv/bin/pip" install django_sendmail_backend
)
#=================================================

View file

@ -63,6 +63,8 @@ ynh_restore_file "$final_path"
# Create the dedicated user (if not existing)
ynh_system_user_create "$app" "/home/$app"
# Allow bash for our user, so he can use hub
chsh --shell /bin/bash "$app"
#=================================================
# RESTORE USER RIGHTS

View file

@ -65,6 +65,7 @@ ynh_add_nginx_config
# Create a system user
ynh_system_user_create "$app" "/home/$app"
chsh --shell /bin/bash "$app"
#=================================================
# SPECIFIC UPGRADE
@ -78,7 +79,9 @@ ynh_system_user_create "$app" "/home/$app"
set +eu
source "${final_path}/venv/bin/activate"
"${final_path}/venv/bin/pip" install Weblate==2.16
"${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2
"${final_path}/venv/bin/pip" install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns psycopg2 python-memcached
# specific to YunoHost package:
"${final_path}/venv/bin/pip" install django_sendmail_backend
)
#=================================================