mirror of
https://github.com/YunoHost-Apps/discourse_ynh.git
synced 2024-09-03 18:26:18 +02:00
commit
c1a386fa83
10 changed files with 91 additions and 65 deletions
43
.github/workflows/updater.sh
vendored
43
.github/workflows/updater.sh
vendored
|
@ -9,9 +9,6 @@
|
||||||
# Since each app is different, maintainers can adapt its contents so as to perform
|
# Since each app is different, maintainers can adapt its contents so as to perform
|
||||||
# automatic actions when a new upstream release is detected.
|
# automatic actions when a new upstream release is detected.
|
||||||
|
|
||||||
# Remove this exit command when you are ready to run this Action
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FETCHING LATEST RELEASE AND ITS ASSETS
|
# FETCHING LATEST RELEASE AND ITS ASSETS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -20,8 +17,8 @@ exit 1
|
||||||
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
|
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
|
||||||
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
|
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
|
||||||
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
|
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
|
||||||
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
|
version=$(curl --silent "https://api.github.com/repos/$repo/tags" | jq -r '.[] | select( .name | contains("rc") or contains("beta") or contains("alpha") | not ) | .name' | sort -V | tail -1)
|
||||||
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
|
assets="https://github.com/discourse/discourse/archive/$version.tar.gz"
|
||||||
|
|
||||||
# Later down the script, we assume the version has only digits and dots
|
# Later down the script, we assume the version has only digits and dots
|
||||||
# Sometimes the release name starts with a "v", so let's filter it out.
|
# Sometimes the release name starts with a "v", so let's filter it out.
|
||||||
|
@ -34,6 +31,7 @@ fi
|
||||||
echo "Current version: $current_version"
|
echo "Current version: $current_version"
|
||||||
echo "Latest release from upstream: $version"
|
echo "Latest release from upstream: $version"
|
||||||
echo "VERSION=$version" >> $GITHUB_ENV
|
echo "VERSION=$version" >> $GITHUB_ENV
|
||||||
|
echo "REPO=$repo" >> $GITHUB_ENV
|
||||||
# For the time being, let's assume the script will fail
|
# For the time being, let's assume the script will fail
|
||||||
echo "PROCEED=false" >> $GITHUB_ENV
|
echo "PROCEED=false" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
@ -47,38 +45,16 @@ elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
|
|
||||||
echo "${#assets[@]} available asset(s)"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE SOURCE FILES
|
# UPDATE SOURCE FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Here we use the $assets variable to get the resources published in the upstream release.
|
# Let's download source tarball
|
||||||
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like.
|
asset_url=$assets
|
||||||
|
|
||||||
# Let's loop over the array of assets URLs
|
|
||||||
for asset_url in ${assets[@]}; do
|
|
||||||
|
|
||||||
echo "Handling asset at $asset_url"
|
echo "Handling asset at $asset_url"
|
||||||
|
|
||||||
# Assign the asset to a source file in conf/ directory
|
src="app"
|
||||||
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
|
|
||||||
# Leave $src empty to ignore the asset
|
|
||||||
case $asset_url in
|
|
||||||
*"admin"*)
|
|
||||||
src="app"
|
|
||||||
;;
|
|
||||||
*"update"*)
|
|
||||||
src="app-upgrade"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
src=""
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# If $src is not empty, let's process the asset
|
|
||||||
if [ ! -z "$src" ]; then
|
|
||||||
|
|
||||||
# Create the temporary directory
|
# Create the temporary directory
|
||||||
tempdir="$(mktemp -d)"
|
tempdir="$(mktemp -d)"
|
||||||
|
@ -106,15 +82,10 @@ SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=$extension
|
SOURCE_FORMAT=$extension
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
SOURCE_FILENAME=
|
SOURCE_FILENAME=
|
||||||
|
SOURCE_EXTRACT=true
|
||||||
EOT
|
EOT
|
||||||
echo "... conf/$src.src updated"
|
echo "... conf/$src.src updated"
|
||||||
|
|
||||||
else
|
|
||||||
echo "... asset ignored"
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPDATE STEPS
|
# SPECIFIC UPDATE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
49
.github/workflows/updater.yml
vendored
Normal file
49
.github/workflows/updater.yml
vendored
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
|
||||||
|
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
|
||||||
|
# This file should be enough by itself, but feel free to tune it to your needs.
|
||||||
|
# It calls updater.sh, which is where you should put the app-specific update steps.
|
||||||
|
name: Check for new upstream releases
|
||||||
|
on:
|
||||||
|
# Allow to manually trigger the workflow
|
||||||
|
workflow_dispatch:
|
||||||
|
# Run it every day at 6:00 UTC
|
||||||
|
schedule:
|
||||||
|
- cron: '0 6 * * *'
|
||||||
|
jobs:
|
||||||
|
updater:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Fetch the source code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Run the updater script
|
||||||
|
id: run_updater
|
||||||
|
run: |
|
||||||
|
# Setting up Git user
|
||||||
|
git config --global user.name 'yunohost-bot'
|
||||||
|
git config --global user.email 'yunohost-bot@users.noreply.github.com'
|
||||||
|
# Run the updater script
|
||||||
|
/bin/bash .github/workflows/updater.sh
|
||||||
|
- name: Commit changes
|
||||||
|
id: commit
|
||||||
|
if: ${{ env.PROCEED == 'true' }}
|
||||||
|
run: |
|
||||||
|
git commit -am "Upgrade to v$VERSION"
|
||||||
|
- name: Create Pull Request
|
||||||
|
id: cpr
|
||||||
|
if: ${{ env.PROCEED == 'true' }}
|
||||||
|
uses: peter-evans/create-pull-request@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
commit-message: Update to version ${{ env.VERSION }}
|
||||||
|
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
|
||||||
|
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
|
||||||
|
signoff: false
|
||||||
|
base: testing
|
||||||
|
branch: ci-auto-update-v${{ env.VERSION }}
|
||||||
|
delete-branch: true
|
||||||
|
title: 'Upgrade to version ${{ env.VERSION }}'
|
||||||
|
body: |
|
||||||
|
Upgrade to v${{ env.VERSION }}
|
||||||
|
draft: false
|
|
@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
||||||
|
|
||||||
Discourse is modern forum software for your community. Use it as a mailing list, discussion forum, long-form chat room, and more!
|
Discourse is modern forum software for your community. Use it as a mailing list, discussion forum, long-form chat room, and more!
|
||||||
|
|
||||||
**Shipped version:** 2.7.13~ynh4
|
**Shipped version:** 2.7.13~ynh5
|
||||||
|
|
||||||
**Demo:** https://try.discourse.org
|
**Demo:** https://try.discourse.org
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
|
||||||
|
|
||||||
Discourse est un logiciel de forum moderne pour votre communauté. Utilisez-le comme liste de diffusion, forum de discussion, salle de discussion longue durée, et plus encore !
|
Discourse est un logiciel de forum moderne pour votre communauté. Utilisez-le comme liste de diffusion, forum de discussion, salle de discussion longue durée, et plus encore !
|
||||||
|
|
||||||
**Version incluse :** 2.7.13~ynh4
|
**Version incluse :** 2.7.13~ynh5
|
||||||
|
|
||||||
**Démo :** https://try.discourse.org
|
**Démo :** https://try.discourse.org
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Discussion platform",
|
"en": "Discussion platform",
|
||||||
"fr": "Plateforme de discussion"
|
"fr": "Plateforme de discussion"
|
||||||
},
|
},
|
||||||
"version": "2.7.13~ynh4",
|
"version": "2.7.13~ynh5",
|
||||||
"url": "http://Discourse.org",
|
"url": "http://Discourse.org",
|
||||||
"upstream": {
|
"upstream": {
|
||||||
"license": "GPL-2.0",
|
"license": "GPL-2.0",
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# dependencies used by the app
|
||||||
pkg_dependencies="g++ libjemalloc1|libjemalloc2 libjemalloc-dev zlib1g-dev libreadline-dev libpq-dev libssl-dev libyaml-dev libcurl4-dev libapr1-dev libxslt1-dev libxml2-dev vim imagemagick postgresql postgresql-server-dev-all postgresql-contrib optipng jhead jpegoptim gifsicle brotli"
|
pkg_dependencies="g++ libjemalloc1|libjemalloc2 libjemalloc-dev zlib1g-dev libreadline-dev libpq-dev libssl-dev libyaml-dev libcurl4-dev libapr1-dev libxslt1-dev libxml2-dev vim imagemagick postgresql postgresql-server-dev-all postgresql-contrib optipng jhead jpegoptim gifsicle brotli"
|
||||||
build_pkg_dependencies=""
|
build_pkg_dependencies=""
|
||||||
|
|
||||||
|
|
|
@ -259,8 +259,6 @@ ynh_app_setting_set --app=$app --key=unicorn_workers --value=$unicorn_workers
|
||||||
libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')"
|
libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')"
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -282,6 +280,8 @@ chmod 750 "$final_path"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$final_path"
|
||||||
chown -R $app:www-data "$final_path"
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -88,8 +88,8 @@ ynh_remove_nginx_config
|
||||||
ynh_script_progression --message="Removing dependencies..."
|
ynh_script_progression --message="Removing dependencies..."
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_ruby
|
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
|
ynh_remove_ruby
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -50,13 +50,6 @@ fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
#=================================================
|
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -87,6 +80,13 @@ ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -161,17 +161,31 @@ then
|
||||||
)
|
)
|
||||||
cp -Rp $tmpdir/log $final_path
|
cp -Rp $tmpdir/log $final_path
|
||||||
cp -p $tmpdir/discourse.conf $final_path/config
|
cp -p $tmpdir/discourse.conf $final_path/config
|
||||||
|
ynh_secure_remove --file="$tmpdir"
|
||||||
|
|
||||||
# Install LDAP plugin
|
# Install LDAP plugin
|
||||||
|
tmpdir=$(mktemp -d)
|
||||||
|
cp -Rp "$final_path/plugins/discourse-ldap-auth/config/settings.yml" $tmpdir
|
||||||
ynh_secure_remove --file="$final_path/plugins/discourse-ldap-auth"
|
ynh_secure_remove --file="$final_path/plugins/discourse-ldap-auth"
|
||||||
mkdir -p "$final_path/plugins/discourse-ldap-auth"
|
mkdir -p "$final_path/plugins/discourse-ldap-auth"
|
||||||
ynh_setup_source --dest_dir="$final_path/plugins/discourse-ldap-auth" --source_id=ldap-auth
|
ynh_setup_source --dest_dir="$final_path/plugins/discourse-ldap-auth" --source_id=ldap-auth
|
||||||
|
cp -p $tmpdir/settings.yml $final_path/plugins/discourse-ldap-auth/config
|
||||||
|
ynh_secure_remove --file="$tmpdir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod 750 "$final_path"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$final_path"
|
||||||
chown -R $app:www-data "$final_path"
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||||
|
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||||
|
ynh_use_ruby
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -186,15 +200,6 @@ if [ "$path_url" != "/" ] ; then
|
||||||
fi
|
fi
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPGRADE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
|
||||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
|
||||||
ynh_use_ruby
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -312,8 +317,6 @@ then
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -342,6 +345,8 @@ chmod 750 "$final_path"
|
||||||
chmod -R o-rwx "$final_path"
|
chmod -R o-rwx "$final_path"
|
||||||
chown -R $app:www-data "$final_path"
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue