Skip to content

Deploy Reference Documentation #52

Deploy Reference Documentation

Deploy Reference Documentation #52

name: Deploy Reference Documentation
on:
workflow_dispatch:
inputs:
version:
description: 'SDK Version'
required: true
type: string
permissions:
id-token: write
jobs:
deploy-reference-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '21'
- run: mvn -f code/sdk dokka:dokka
- name: Prepare for deployment
run: |
git config --global user.email "[email protected]"
git config --global user.name "eg-oss-ci"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
git fetch --all
mkdir -p docs/${{ github.event.inputs.version }}
mv code/sdk/target/dokka/* docs/${{ github.event.inputs.version }}
git add .
git commit -m "chore: publishing docs for version ${{ github.event.inputs.version }}"
BRANCH_EXISTS=$(git ls-remote --heads origin gh-pages | wc -l)
if [ "$BRANCH_EXISTS" -eq 0 ]; then
git checkout --orphan gh-pages
else
git checkout gh-pages
git pull origin gh-pages
fi
git checkout $CURRENT_BRANCH -- docs
mv docs/* .
- name: Build Index Page
run: |
rm -rf docs code
touch index.html
echo "<!DOCTYPE html><html><head><title>Expedia Group Rapid SDK Reference Documentation</title></head><body><h1>Expedia Group Rapid SDK Reference Documentation</h1><ul>" > index.html
for dir in $(ls -d */); do
if [ "$dir" == "${{ github.event.inputs.version }}/" ]; then
echo "<li><a href=\"${dir}index.html\">${dir}</a></li>" >> index.html
echo "<li><a href=\"latest/index.html\">Latest (Version ${{ github.event.inputs.version }})</a></li>" >> index.html
continue
fi
if [ "$dir" == "latest/" ]; then
continue
fi
echo "<li><a href=\"${dir}\index.html\">${dir}</a></li>" >> index.html
done
echo "</ul></body></html>" >> index.html
ln -sfn ./${{ github.event.inputs.version }} ./latest
- name: Commit
run: |
git add .
git commit -m "chore: publishing docs for version ${{ github.event.inputs.version }}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
commit-message: "chore: publishing docs for version ${{ github.event.inputs.version }}"
body: "This PR updates the reference documentation for version ${{ github.event.inputs.version }}."
title: "chore: reference docs update for version ${{ github.event.inputs.version }}"
branch: "docs-update-${{ github.event.inputs.version }}"