Skip to content

Main GH Actions workflow #3251

Main GH Actions workflow

Main GH Actions workflow #3251

Workflow file for this run

name: Main GH Actions workflow
on:
push:
branches:
- main
schedule:
- cron: "06 12 * * *"
workflow_dispatch:
inputs:
branch:
description: 'Documentation page deployment source branch'
required: true
default: main
# Required for the deployment to be able to upload to the "gh-pages" branch
# (since the repo settings for default actions permission defaults to read only)
permissions:
contents: write
env:
CHANGELOG_LMS8_SRC: https://raw.githubusercontent.com/LMS-Community/slimserver/HEAD/Changelog8.html
CHANGELOG_LMS8_TARGET: docs/getting-started/changelog-lms8.md
CHANGELOG_LMS9_SRC: https://raw.githubusercontent.com/LMS-Community/slimserver/HEAD/Changelog9.html
CHANGELOG_LMS9_TARGET: docs/getting-started/changelog-lms9.md
PLUGIN_TARGET: docs/plugins/directory.md
SQUEEZELITE_MANPAGE_SRC: https://raw.githubusercontent.com/ralph-irving/squeezelite/master/doc/squeezelite.1
SQUEEZELITE_MANPAGE_TARGET: docs/players-and-controllers/squeezelite-manpage.md
STRINGS_COVERAGE_JSON: docs/contributing/strings-coverage.json
STATS_JSON: docs/analytics/stats.json
jobs:
check-slimserver-commit:
name: Check latest slimserver commit
runs-on: ubuntu-24.04
outputs:
changed: ${{ steps.check.outputs.changed }}
latest_commit: ${{ steps.get_commit.outputs.latest_commit }}
steps:
- name: Get latest commit hash from slimserver
id: get_commit
run: |
latest_commit=$(git ls-remote https://github.com/LMS-Community/slimserver.git HEAD | awk '{print $1}')
echo "latest_commit=$latest_commit" >> $GITHUB_OUTPUT
- name: Cache last known commit hash
id: restore_commit
uses: actions/cache@v4
with:
path: .slimserver_last_commit
key: slimserver-last-commit
- name: Check if commit has changed
id: check
run: |
last_commit=""
if [ -f .slimserver_last_commit ]; then
last_commit=$(cat .slimserver_last_commit)
fi
if [ "$last_commit" != "${{ steps.get_commit.outputs.latest_commit }}" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
echo "${{ steps.get_commit.outputs.latest_commit }}" > .slimserver_last_commit
get-external-changelog:
name: Import external data sources
needs: check-slimserver-commit
if: needs.check-slimserver-commit.outputs.changed == 'true'
runs-on: ubuntu-24.04
steps:
- name: Install html2md repository and other depedencies
run: |
# add repo for html2md
curl -1sLf 'https://dl.cloudsmith.io/public/suntong/repo/setup.deb.sh' | sudo -E bash
if [ "$ACT" == "true" ]; then
sudo apt-get update
# apt-cache policy html2md
sudo apt install -y html2md python3-babel
fi
- name: Install APT depedencies
if: ${{ !env.ACT }}
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: html2md python3-babel
version: 1
- name: Checkout documentation
uses: actions/checkout@v5
- name: Get changelog and convert to markdown
run: |
html2md -i $CHANGELOG_LMS8_SRC > $CHANGELOG_LMS8_TARGET
sed -Ei 's/http:\/\/raw.githubusercontent.com.*?#v([1-9]+)\.([0-9]+)\.([0-9]+)\)/#version-\1\2\3)/' $CHANGELOG_LMS8_TARGET
sed -Ei 's/^\s\s*/\t/g' $CHANGELOG_LMS8_TARGET
html2md -i $CHANGELOG_LMS9_SRC > $CHANGELOG_LMS9_TARGET
sed -Ei 's/http:\/\/raw.githubusercontent.com.*?#v([1-9]+)\.([0-9]+)\.([0-9]+)\)/#version-\1\2\3)/' $CHANGELOG_LMS9_TARGET
sed -Ei 's/http:\/\/raw.githubusercontent.com\/Changelog8.html/changelog-lms8.md/' $CHANGELOG_LMS9_TARGET
sed -Ei 's/^\s\s*/\t/g' $CHANGELOG_LMS9_TARGET
- name: Get squeezelite manpage and convert to markdown
run: |
: # TODO not the most elegant way of running a Perl script from Github
: # We download this specific commit as this version is verified
curl -O https://raw.githubusercontent.com/mle86/man-to-md/f484095dbbe741469ff5180f20d829172c2ff571/man-to-md.pl
echo -e "---\nlayout: default\ntitle: squeezelite(1) manpage\nhide:\n - toc\n---\n" >$SQUEEZELITE_MANPAGE_TARGET
perl man-to-md.pl <(curl -s $SQUEEZELITE_MANPAGE_SRC) >>$SQUEEZELITE_MANPAGE_TARGET
rm man-to-md.pl
- name: Check out LMS code for strings coverage
uses: actions/checkout@v5
with:
repository: LMS-Community/slimserver
path: slimserver
- name: Get translation coverage of slimserver strings.txt
run: |
tools/get-strings-coverage.py <(find slimserver -name strings.txt -exec cat {} \;) >$STRINGS_COVERAGE_JSON
rm -rf slimserver
- name: Commit changes
if: ${{ !env.ACT }}
run: |
git config user.name github-actions
git config user.email [email protected]
git add --all
if [ -n "$(git status --porcelain)" ]; then
git commit -m "Update external data sources"
git push
else
echo "No changes to commit";
fi
deploy-mkdocs:
name: Build website and publish to gh-pages branch
needs: get-external-changelog
if: always() # run even if previous job failed or was skipped
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.event.inputs.branch }}
- name: Install dependencies
if: ${{ !env.ACT }}
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libjson-perl libwww-perl libxml-simple-perl libyaml-perl
version: 1
- name: Install depedencies (ACT mode)
if: ${{ env.ACT }}
run: |
sudo apt-get update
sudo apt-get install -y libjson-perl libwww-perl libxml-simple-perl libyaml-perl
- name: Get release downloads and embed in Getting Started document
run: |
tools/build-server-downloads-page.pl
- name: Get plugin repository and convert to markdown
run: |
tools/build-plugin-repository.pl > $PLUGIN_TARGET
- name: Get analytics data
# if: github.event_name == 'schedule'
run: |
tools/get-analytics-data.pl > $STATS_JSON
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v6
with:
python-version: 3.x
# evaluate the week number to use in the cache key
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: |
pip install mkdocs-material
pip install mkdocs-macros-plugin
pip install mkdocs-charts-plugin
- run: mkdocs gh-deploy --force
if: ${{ !env.ACT }}