-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a bash script to lookup the material insiders latest version …
…and compare it to the installed version and install the newer version if it is different. Adding a github action to do that automatically with a pull request. (#1405)
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# Source an env file if it exists. | ||
if [ -f .env ]; then | ||
source .env | ||
fi | ||
|
||
# Check environment. | ||
if [ -z "${GH_TOKEN:-}" ]; then | ||
echo "Github token for material-insiders access needed. Ask in #docs channel for access." 1>&2 | ||
exit 1 | ||
fi | ||
|
||
material_insiders_repo="https://github.com/squidfunk/mkdocs-material-insiders.git" | ||
|
||
# Get latest tag from material-insiders git repo. | ||
# Got solution from https://stackoverflow.com/questions/29780641/how-to-clone-latest-tag-in-a-git-repo. | ||
latest_tag=$(git ls-remote --tags --exit-code --refs "$material_insiders_repo" \ | ||
| sed -E 's/^[[:xdigit:]]+[[:space:]]+refs\/tags\/(.+)/\1/g' \ | ||
| sort --version-sort | tail -n1) | ||
|
||
# Get latest installed tag from poetry. | ||
installed_tag=$(poetry -C .config/mkdocs/ show mkdocs-material | awk '/version/ { print $3 }' | sed 's/+insiders./-insiders-/') | ||
|
||
# Compare tags | ||
if [ "$latest_tag" = "$installed_tag" ]; then | ||
echo "Latest material-insiders version $latest_tag already installed." | ||
else | ||
echo "Newer material-insiders version available: $latest_tag. Installing..." | ||
poetry -C .config/mkdocs/ add git+$material_insiders_repo#"$latest_tag" | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Checking material insiders update | ||
|
||
on: | ||
# Automatic check monthly | ||
schedule: | ||
- cron: "0 10 1 * *" | ||
# Manually triggered using GitHub's UI | ||
workflow_dispatch: | ||
|
||
jobs: | ||
mkdocs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
- uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.3.2 | ||
- name: Run material insiders script to check version. | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
run: ./.config/mkdocs/check-material-insiders-version.sh | ||
- name: Create pull request if there is a new version | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
commit-message: Update material insiders version to latest version | ||
title: Update material insiders version to latest version | ||
body: Verify the new version works and there are no side effects (theme color reverting). Confirm all checks are passing. | ||
branch: update-material-insiders |