|
| 1 | +name: "[Docs] Generate version after Helm chart sync" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + generate-docs-version: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout documentation repo |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + path: target-repo |
| 17 | + |
| 18 | + - name: Install jq and curl |
| 19 | + run: sudo apt-get update && sudo apt-get install -y jq curl |
| 20 | + |
| 21 | + - name: Get latest release from Homarr main repo |
| 22 | + id: get-version |
| 23 | + run: | |
| 24 | + set -eux |
| 25 | + cd target-repo |
| 26 | +
|
| 27 | + LATEST_RELEASE=$(curl -s https://api.github.com/repos/homarr-labs/homarr/releases/latest) |
| 28 | + VERSION=$(echo "$LATEST_RELEASE" | jq -r .tag_name | sed 's/^v//') |
| 29 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 30 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 31 | +
|
| 32 | + IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" |
| 33 | + MAJOR_MINOR="$MAJOR.$MINOR" |
| 34 | + echo "MAJOR_MINOR=$MAJOR_MINOR" >> $GITHUB_ENV |
| 35 | + echo "major_minor=$MAJOR_MINOR" >> $GITHUB_OUTPUT |
| 36 | +
|
| 37 | + EXISTS=$(jq -r --arg prefix "$MAJOR_MINOR." '[.[] | select(startswith($prefix))] | length' versions.json) |
| 38 | +
|
| 39 | + if [ "$EXISTS" -eq 0 ]; then |
| 40 | + echo "should_generate=true" >> $GITHUB_OUTPUT |
| 41 | + else |
| 42 | + echo "should_generate=false" >> $GITHUB_OUTPUT |
| 43 | + fi |
| 44 | +
|
| 45 | + - name: Install Node and pnpm |
| 46 | + uses: pnpm/action-setup@v2 |
| 47 | + with: |
| 48 | + version: 8 |
| 49 | + - uses: actions/setup-node@v4 |
| 50 | + with: |
| 51 | + node-version: 20 |
| 52 | + |
| 53 | + - name: Generate versioned docs |
| 54 | + if: steps.get-version.outputs.should_generate == 'true' |
| 55 | + run: | |
| 56 | + cd target-repo |
| 57 | + pnpm install |
| 58 | + pnpm run docusaurus docs:version ${{ steps.get-version.outputs.version }} |
| 59 | +
|
| 60 | + - name: Commit versioned docs |
| 61 | + if: steps.get-version.outputs.should_generate == 'true' |
| 62 | + run: | |
| 63 | + cd target-repo |
| 64 | + git config user.name "github-actions[bot]" |
| 65 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 66 | + git add . |
| 67 | + git commit -m "docs(version): Add versioned docs for ${{ steps.get-version.outputs.version }}" || echo "No changes to commit" |
| 68 | + git push |
0 commit comments