Skip to content

ci(versioning): Generate version after Helm chart sync #267

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
68 changes: 68 additions & 0 deletions .github/workflows/generate-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: "[Docs] Generate version after Helm chart sync"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is misleading, nothing is done here with a helm chart sync


on:
push:
branches:
- master
Comment on lines +3 to +6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Add a workflow dispatch?


jobs:
generate-docs-version:
runs-on: ubuntu-latest

steps:
- name: Checkout documentation repo
uses: actions/checkout@v4
with:
path: target-repo

- name: Install jq and curl
run: sudo apt-get update && sudo apt-get install -y jq curl

- name: Get latest release from Homarr main repo
id: get-version
run: |
set -eux
cd target-repo

LATEST_RELEASE=$(curl -s https://api.github.com/repos/homarr-labs/homarr/releases/latest)
VERSION=$(echo "$LATEST_RELEASE" | jq -r .tag_name | sed 's/^v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT

IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
MAJOR_MINOR="$MAJOR.$MINOR"
echo "MAJOR_MINOR=$MAJOR_MINOR" >> $GITHUB_ENV
echo "major_minor=$MAJOR_MINOR" >> $GITHUB_OUTPUT

EXISTS=$(jq -r --arg prefix "$MAJOR_MINOR." '[.[] | select(startswith($prefix))] | length' versions.json)

if [ "$EXISTS" -eq 0 ]; then
echo "should_generate=true" >> $GITHUB_OUTPUT
else
echo "should_generate=false" >> $GITHUB_OUTPUT
fi

- name: Install Node and pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20

- name: Generate versioned docs
if: steps.get-version.outputs.should_generate == 'true'
run: |
cd target-repo
pnpm install
pnpm run docusaurus docs:version ${{ steps.get-version.outputs.version }}

- name: Commit versioned docs
if: steps.get-version.outputs.should_generate == 'true'
run: |
cd target-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "docs(version): Add versioned docs for ${{ steps.get-version.outputs.version }}" || echo "No changes to commit"
git push
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this result in an infinite loop (see triggers?)