diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 0000000..80d4473 --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +#================================================= +# PACKAGE UPDATING HELPER +#================================================= + +# This script is meant to be run by GitHub Actions +# The YunoHost-Apps organisation offers a template Action to run this script periodically + +#================================================= +# FETCHING LATEST RELEASE AND ITS ASSETS +#================================================= + +# Fetching information +current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') +current_yunorunner_release=$(grep -Po 'yunorunner_release="\K.*?(?=")' scripts/_common.sh) +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) +version=$(curl --silent "https://api.github.com/repos/$repo/commits/master" | jq -r '.commit.committer.date | split("T")[0] | gsub("-";".")') +yunorunner_release=$(curl --silent "https://api.github.com/repos/$repo/commits/master" | jq -r '.sha') + +# Setting up the environment variables +echo "Current version: $current_version" +echo "Latest release from upstream: $version" +echo "VERSION=$version" >> $GITHUB_ENV +# For the time being, let's assume the script will fail +echo "PROCEED=false" >> $GITHUB_ENV + +# Proceed only if the retrieved version is greater than the current one +if [[ ! "$version" > "$current_version" ]]; then + echo "::warning ::No new version available" + exit 0 +# Proceed only if a PR for this new version does not already exist +elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then + echo "::warning ::A branch already exists for this update" + exit 0 +fi + +#================================================= +# UPDATE SOURCE FILES +#================================================= + +sed -i "s/$current_yunorunner_release/$yunorunner_release/gi" scripts/_common.sh + +#================================================= +# SPECIFIC UPDATE STEPS +#================================================= + +# Any action on the app's source code can be done. +# The GitHub Action workflow takes care of committing all changes after this script ends. + +#================================================= +# GENERIC FINALIZATION +#================================================= + +# Replace new version in manifest +echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json + +# No need to update the README, yunohost-bot takes care of it + +# The Action will proceed only if the PROCEED environment variable is set to true +echo "PROCEED=true" >> $GITHUB_ENV +exit 0 + diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..5f1dcc1 --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,50 @@ +# 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 ' + author: 'yunohost-bot ' + 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 + diff --git a/README.md b/README.md index 23885a7..73f7418 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in CI runner of YunoHost -**Shipped version:** 2021.09.22~ynh3 +**Shipped version:** 2022.01.09~ynh1 diff --git a/README_fr.md b/README_fr.md index b2095e6..5f58092 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Runner d'intégration continue de YunoHost -**Version incluse :** 2021.09.22~ynh3 +**Version incluse :** 2022.01.09~ynh1 diff --git a/check_process b/check_process index f0f31f4..1571f8c 100644 --- a/check_process +++ b/check_process @@ -1,6 +1,6 @@ ;; Test complet ; pre-install - sudo git clone https://github.com/YunoHost/CI_package_check /home/CI_package_check + sudo git clone --quiet https://github.com/YunoHost/CI_package_check /home/CI_package_check ; Manifest domain="domain.tld" path="/path" diff --git a/conf/nginx.conf b/conf/nginx.conf index 4f337a3..ff7c444 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -13,10 +13,19 @@ location __PATH__/ { location __PATH__/logs { alias /home/CI_package_check/logs/; autoindex on; + default_type "text/plain"; } - + location __PATH__/badges/ { alias /home/CI_package_check/badges/; autoindex on; } + + location __PATH__/summary/ { + alias /home/CI_package_check/summary/; + autoindex on; + etag off; + more_set_headers "Cache-control: max-age=300, s-maxage=300"; + error_page 404 /ci/summary/empty.png; + } } diff --git a/manifest.json b/manifest.json index f3fd036..30c1710 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "CI runner of YunoHost", "fr": "Runner d'intégration continue de YunoHost" }, - "version": "2021.09.22~ynh3", + "version": "2022.01.09~ynh1", "url": "https://github.com/YunoHost/yunorunner", "upstream": { "license": "GPL-3.0-or-later", @@ -28,7 +28,7 @@ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" diff --git a/scripts/_common.sh b/scripts/_common.sh index 88c8417..1216083 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,7 +9,7 @@ pkg_dependencies="python3-venv python3-dev python3-pip sqlite3" yunorunner_repository="https://github.com/YunoHost/yunorunner" -yunorunner_release="0e87f07e8bcb1f3aee055a694f3c7198e22b4019" +yunorunner_release="de28fea3b51a3f5b4e3d0bdc956e2f172cea592c" #================================================= # PERSONAL HELPERS diff --git a/scripts/change_url b/scripts/change_url index ba60148..d9ca583 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -79,7 +79,7 @@ fi #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped YunoRunner CI" +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped YunoRunner CI" --timeout=30 #================================================= # MODIFY URL IN NGINX CONF diff --git a/scripts/install b/scripts/install index 202e137..91ac024 100644 --- a/scripts/install +++ b/scripts/install @@ -145,7 +145,7 @@ yunohost service add $app --description="$app daemon for YunoRunner" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30 #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index 67bef3d..a51a6ae 100644 --- a/scripts/restore +++ b/scripts/restore @@ -113,7 +113,7 @@ yunohost service add $app --description="$app daemon for YunoRunner" #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30 #================================================= # DEACTIVE MAINTENANCE MODE diff --git a/scripts/upgrade b/scripts/upgrade index 677b0ec..ee7e676 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -183,7 +183,7 @@ yunohost service add $app --description="$app daemon for YunoRunner" #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30 #================================================= # DEACTIVE MAINTENANCE MODE