Skip to content

Commit

Permalink
feature/IVYPORTAL-18151-Create-Github-Action-for-Building-Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ntloc-axonivy committed Dec 25, 2024
1 parent 8071a15 commit 79b0e43
Showing 1 changed file with 60 additions and 55 deletions.
115 changes: 60 additions & 55 deletions .github/workflows/portal-documentation.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Portal Documentation
run-name: Build and Deploy Documentation 🚀
on:
schedule:
- cron: '0 0 * * *' # Equivalent to '@midnight'
workflow_dispatch:
inputs:
ivyVersion:
Expand All @@ -15,67 +17,70 @@ jobs:
prepare-document:
runs-on: portal-01
steps:
- uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: test summary
run: echo "### Documentation Build Warnings" >> $GITHUB_STEP_SUMMARY

- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.8
# - uses: actions/checkout@v4
# - name: Set up Java
# uses: actions/setup-java@v4
# with:
# distribution: 'temurin'
# java-version: '21'

- name: Get current version
id: get_version
run: |
VERSION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout -f Documentation/pom.xml)
if [[ "$VERSION" == "null object or invalid expression" ]]; then
echo "Error: could not evaluate maven revision property"
# Stops the workflow if the condition is met
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Version is $VERSION"
# - name: Set up Maven
# uses: stCarolas/setup-maven@v5
# with:
# maven-version: 3.9.8

# - name: Get current version
# id: get_version
# run: |
# VERSION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout -f Documentation/pom.xml)
# if [[ "$VERSION" == "null object or invalid expression" ]]; then
# echo "Error: could not evaluate maven revision property"
# # Stops the workflow if the condition is met
# exit 1
# fi
# echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# echo "Version is $VERSION"

- name: Unzip portal screenshots
run: |
unzip /mnt/portal02/document-screenshots/portal-document-screenshots-selenide-${{ steps.get_version.outputs.version }}.zip \
-d Documentation/portal-guide/source/screenshots
# - name: Unzip portal screenshots
# run: |
# unzip /mnt/portal02/document-screenshots/portal-document-screenshots-selenide-${{ steps.get_version.outputs.version }}.zip \
# -d Documentation/portal-guide/source/screenshots

- name: Generate resources
run: |
mvn clean process-resources -Divy.engine.version=[13.1.0,] -Divy.engine.download.url=https://developer.axonivy.com/permalink/dev/axonivy-engine.zip -f Documentation/public-api/pom.xml
mvn clean generate-resources -f Documentation/pom.xml
# - name: Generate resources
# run: |
# mvn clean process-resources -Divy.engine.version=[13.1.0,] -Divy.engine.download.url=https://developer.axonivy.com/permalink/dev/axonivy-engine.zip -f Documentation/public-api/pom.xml
# mvn clean generate-resources -f Documentation/pom.xml

- name: Run substitute
shell: bash
run: chmod +x Documentation/portal-guide/substitute.sh && Documentation/portal-guide/substitute.sh ${{ inputs.ivyVersion }}
# - name: Run substitute
# shell: bash
# run: chmod +x Documentation/portal-guide/substitute.sh && Documentation/portal-guide/substitute.sh ${{ inputs.ivyVersion }}

- name: Build Documentation HTML
run: |
docker run -u root:root --rm -v ${{ github.workspace }}:/workspace -w /workspace/Documentation/portal-guide \
axonivy/build-container:read-the-docs-2 make -C /doc-build html BASEDIR='/workspace/Documentation/portal-guide' VERSION=${{ steps.get_version.outputs.version }}
# - name: Build Documentation HTML
# run: |
# docker run -u root:root --rm -v ${{ github.workspace }}:/workspace -w /workspace/Documentation/portal-guide \
# axonivy/build-container:read-the-docs-2 make -C /doc-build html BASEDIR='/workspace/Documentation/portal-guide' VERSION=${{ steps.get_version.outputs.version }}

- name: Install or deploy document
run: |
if [[ "${{ steps.get_version.outputs.version }}" == *SNAPSHOT* ]]; then
PHASE="install"
else
PHASE="deploy"
fi
echo "Running 'clean $PHASE' for version ${{ steps.get_version.outputs.version }}"
mvn clean $PHASE -f Documentation/pom.xml
# - name: Install or deploy document
# run: |
# if [[ "${{ steps.get_version.outputs.version }}" == *SNAPSHOT* ]]; then
# PHASE="install"
# else
# PHASE="deploy"
# fi
# echo "Running 'clean $PHASE' for version ${{ steps.get_version.outputs.version }}"
# mvn clean $PHASE -f Documentation/pom.xml

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: documentation
path: |
Documentation/*/build/html/**/*
Documentation/*/target/*.zip
# - name: Upload artifacts
# uses: actions/upload-artifact@v4
# with:
# name: documentation
# path: |
# Documentation/*/build/html/**/*
# Documentation/*/target/*.zip

- name: Cleanup
shell: bash
run: rm -r --force ${{ github.workspace }}\*
# - name: Cleanup
# shell: bash
# run: rm -rf ${{ github.workspace }}/*

0 comments on commit 79b0e43

Please sign in to comment.