Skip to content

Deploy Reference Documentation #43

Deploy Reference Documentation

Deploy Reference Documentation #43

name: Deploy Reference Documentation
on:
workflow_dispatch:
inputs:
version:
description: 'SDK Version'
required: true
type: string
# push:
# branches:
# - mohnoor94/docs
# - main
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: |
touch index.html
echo "<!DOCTYPE html><html><head><title>Expedia Group SDK Reference Documentation</title></head><body><h1>Expedia Group SDK Reference Documentation</h1><ul>" > index.html
for dir in $(ls -d */); do
echo "<li><a href=\"${dir}index.html\">${dir}</a></li>" >> index.html
done
echo "</ul></body></html>" >> index.html
- 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 }}"