Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: update changelog at test.le.tv #14

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/tools-update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: tools-update-changelog
on:
workflow_dispatch:
schedule:
- cron: "*/30 * * * *"

jobs:
update_changelog:
runs-on: [self-hosted, scripts]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
repository: "LibreELEC/actions"
path: "actions"

- name: Update changelog at test.libreelec.tv
run: |
echo "Updating changelog at test.libreelec.tv"
ls -lah
echo "---------------"
pwd
cd "actions/"
ls -lah
echo "---------------"
tail ./scripts/update_changelog.sh
echo "---------------"
ssh ${{ secrets.NIGHTLY_HOST_USERNAME }}@${{ secrets.NIGHTLY_HOST }} -p ${{ secrets.NIGHTLY_HOST_PORT }} \
"bash -s" < ./scripts/update_changelog.sh
51 changes: 51 additions & 0 deletions scripts/update_changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# abort at error
set -e

# create changelog
generate_changelog() {
# html header
cat <<EOF
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://test.libreelec.tv/css/listing.css"/>
</head>
<body>
<h2> Changelog</h2>
<table class="changelogTable" style="width: 100%;">
<tbody>
EOF

# get commits from GH API
gh_output="$(curl -sH "Accept: application/vnd.github.v3+json" https://api.github.com/repos/LibreELEC/LibreELEC.tv/commits?per_page=60 | jq '.[] | "\(.commit.author.date | .[0:10]) \(.sha | .[0:7]) \(.commit.message)"' | grep "Merge pull request")"

while IFS= read -r line; do
# PR link
var_pr="$(grep -oE '#[0-9]+' <<<"$line")"

# PR message
var_message="$(grep -oP '(?<=\\n\\n)(.*)(?=\")' <<<"$line")"

# PR date at merge
var_date="$(grep -oP '(?<=^")[0-9-]{10}' <<<"$line")"

# git shorthash
var_hash="$(grep -oP '(?<=^"[0-9-]{10} )[0-9a-f]{7}' <<<"$line")"

# output line
echo "<tr><td>$var_date ($var_hash):</td><td><a href=\"https://github.com/LibreELEC/LibreELEC.tv/pull/${var_pr//#/}\" target="_blank" rel="noopener noreferrer">${var_pr}</a></td><td>${var_message}</td></tr>"
done <<<"$gh_output"

# html footer
cat <<EOF
</tbody>
</table>
</body>
</html>
EOF
}

# generate and output to file
generate_changelog >/var/www/test/css/changelog.html