Main GH Actions workflow #1653
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main GH Actions workflow | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "06 2 * * *" | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'Documentation page deployment source branch' | |
required: true | |
default: main | |
# Not yet heavily tested - therefore disabled | |
# | |
# Allow to stop obsolete workflows | |
#concurrency: | |
# group: ci-buildtrain-${{ github.ref }}-1 | |
# cancel-in-progress: true | |
# 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: | |
get-external-changelog: | |
name: Import external data sources | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Install Go to satisfy dependencies | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '>=1.23.0' | |
- name: Install dependencies | |
run: | | |
go install github.com/suntong/html2md@v1.5.0 | |
sudo apt-get update | |
sudo apt-get install -y libjson-perl libwww-perl libxml-simple-perl libyaml-perl python3-babel | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Get changelog and convert to markdown | |
run: | | |
export PATH=${PATH}:`go env GOPATH`/bin | |
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: 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 | |
run: | | |
tools/get-analytics-data.pl > $STATS_JSON | |
- name: Check out LMS code for strings coverage | |
uses: actions/checkout@v4 | |
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 github-actions@github.com | |
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: | |
if: ${{ always() }} | |
name: Build website and publish to gh-pages branch | |
needs: get-external-changelog | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.branch }} | |
- 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@v5 | |
with: | |
python-version: 3.x | |
- 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 |