Skip to content

Docs

Docs #154

Workflow file for this run

name: Docs
on:
schedule:
- cron: '0 9 * * 1'
workflow_dispatch:
inputs:
version-number:
type: string
description: What is the new version number (ex. v0.28.0) for the website? If updating dev, leave this blank.
default: master
required: false
permissions:
id-token: write
contents: read
jobs:
documentation:
runs-on: ubuntu-latest
steps:
- name: Checkout DJL Repo
uses: actions/checkout@v4
- name: Update versions.json
env:
NEW_VERSION: '${{ github.event.inputs.version-number }}'
run: |
# Check for duplicate
DUPLICATE=$(jq --arg v "$NEW_VERSION" 'any(.version == $v)' versions.json)
if [ "$DUPLICATE" = "true" ]; then
echo "Version $NEW_VERSION already exists. Skipping update."
echo "duplicate=true" >> $GITHUB_OUTPUT
else
jq --arg v "$NEW_VERSION" '
def custom_sort:
. as $versions |
(
map(select(.version | test("^[0-9]+([.][0-9]+)*$"))) |
sort_by(.version | split(".") | map(tonumber))
) + (
$versions - map(select(.version | test("^[0-9]+([.][0-9]+)*$")))
);
([{"version": $v, "title": $v, "aliases": []}] + .) | custom_sort
' versions.json > temp.json && mv temp.json versions.json
echo "duplicate=false" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: steps.update_json.outputs.duplicate == 'false'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add versions.json
git commit -m "Add new version ${{ github.event.inputs.new_version }} to versions.json and sort"
git push
- name: No changes made
if: steps.update_json.outputs.duplicate == 'true'
run: echo "No changes were made as the version already exists."