From 82d6d2ca4fac51437ad07e2e90a81c53fad101d1 Mon Sep 17 00:00:00 2001
From: Maxim Thomas <maxim.thomas@gmail.com>
Date: Wed, 30 Oct 2024 14:50:53 +0000
Subject: [PATCH] depoloy.yml: Fix documents deploy  (#449)

---
 opendj-doc-generated-ref/src/main/ant/zip.xml |   16 +-------
 opendj-doc-generated-ref/pom.xml              |   82 ++++++++++++++++++++++++++++-------------
 .github/workflows/deploy.yml                  |    7 ++-
 3 files changed, 63 insertions(+), 42 deletions(-)

diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 74aa997..105a62d 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -157,5 +157,8 @@
           rm -rf ${REPO_NAME_LC}/modules
           cp -R ../${SITE_DOC_FOLDER}/target/asciidoc/antora/modules ../doc.openidentityplatform.org/${REPO_NAME_LC}
           git add -A
-          git commit -a -m "upload ${{github.event.repository.name}} docs after deploy ${{ github.sha }}"
-          git push --force https://github.com/OpenIdentityPlatform/doc.openidentityplatform.org.git
+          if ! git diff-index --quiet HEAD; then
+            echo "committing changes to the docs repository"
+            git commit -a -m "upload ${{github.event.repository.name}} docs after deploy ${{ github.sha }}"
+            git push --force https://github.com/OpenIdentityPlatform/doc.openidentityplatform.org.git
+          fi
diff --git a/opendj-doc-generated-ref/pom.xml b/opendj-doc-generated-ref/pom.xml
index 3d03803..0da2a8a 100644
--- a/opendj-doc-generated-ref/pom.xml
+++ b/opendj-doc-generated-ref/pom.xml
@@ -548,32 +548,6 @@
                     </plugin>
 
                     <plugin>
-                        <artifactId>maven-antrun-plugin</artifactId>
-                        <executions>
-                            <execution>
-                                <id>copy-man-pages</id>
-                                <phase>package</phase>
-                                <goals>
-                                    <goal>run</goal>
-                                </goals>
-                                <configuration>
-                                    <tasks>
-                                        <copy todir="${project.build.directory}/asciidoc/source/man-pages">
-                                            <fileset dir="${basedir}/src/main/asciidoc/man-pages" includes="**/*" />
-                                        </copy>
-                                        <copy todir="${project.build.directory}/asciidoc/source/partials">
-                                            <fileset dir="${basedir}/src/main/asciidoc/man-pages" includes="**/*" />
-                                            <fileset dir="${project.build.directory}/asciidoc/source/man-pages" includes="**/*" />
-                                        </copy>
-                                        <delete>
-                                            <fileset dir="${project.build.directory}/asciidoc/source/man-pages" includes="man-*-subcommands-ref*" />
-                                        </delete>
-                                    </tasks>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-                    <plugin>
                         <groupId>org.asciidoctor</groupId>
                         <artifactId>asciidoctor-maven-plugin</artifactId>
                         <version>2.2.6</version>
@@ -671,6 +645,62 @@
                             </execution>
                         </executions>
                     </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-antrun-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>copy-man-pages</id>
+                                <phase>prepare-package</phase>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <configuration>
+                                    <tasks>
+                                        <copy todir="${project.build.directory}/asciidoc/source/man-pages">
+                                            <fileset dir="${basedir}/src/main/asciidoc/man-pages" includes="**/*" />
+                                        </copy>
+                                        <copy todir="${project.build.directory}/asciidoc/source/partials">
+                                            <fileset dir="${basedir}/src/main/asciidoc/man-pages" includes="**/*" />
+                                            <fileset dir="${project.build.directory}/asciidoc/source/man-pages" includes="**/*" />
+                                        </copy>
+                                        <delete>
+                                            <fileset dir="${project.build.directory}/asciidoc/source/man-pages" includes="man-*-subcommands-ref*" />
+                                        </delete>
+                                    </tasks>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>zip-docs</id>
+                                <phase>package</phase>
+                                <configuration>
+                                    <target>
+                                        <property name="compress_formats" value="pdf" />
+                                        <property name="project_name" value="${project.name}" />
+                                        <ant antfile="${basedir}/src/main/ant/zip.xml">
+                                            <target name="docs" />
+                                        </ant>
+                                    </target>
+                                </configuration>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <dependencies>
+                            <dependency>
+                                <groupId>ant-contrib</groupId>
+                                <artifactId>ant-contrib</artifactId>
+                                <version>${ant.contrib.version}</version>
+                                <exclusions>
+                                    <exclusion>
+                                        <groupId>ant</groupId>
+                                        <artifactId>ant</artifactId>
+                                    </exclusion>
+                                </exclusions>
+                            </dependency>
+                        </dependencies>
+                    </plugin>
                 </plugins>
             </build>
         </profile>
diff --git a/opendj-doc-generated-ref/src/main/ant/zip.xml b/opendj-doc-generated-ref/src/main/ant/zip.xml
index 39ddb42..0b7292f 100644
--- a/opendj-doc-generated-ref/src/main/ant/zip.xml
+++ b/opendj-doc-generated-ref/src/main/ant/zip.xml
@@ -1,22 +1,10 @@
 <project name="zip">
     <target name="docs">
         <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
-        <foreach param="docname" target="formats" inheritall="true">
-            <path>
-                <dirset dir="${basedir}/src/main/docbkx/" casesensitive="yes">
-                    <include name="*/"/>
-                    <exclude name="*/*/**"/>
-                    <exclude name="shared"/>
-                </dirset>
-            </path>
-            <mapper type="flatten"/>
-        </foreach>
-    </target>
-    <target name="formats">
         <foreach param="format" list="${compress_formats}" target="dozip" inheritall="true"/>
     </target>
     <target name="dozip" >
-        <echo message="compressing ${format} ${docname} from ${project_build_dir}/docbkx/${format}/${docname} to ${project_build_dir}/docbkx/${format}/${docname}.zip"/>
-        <zip basedir="${project.build.directory}/docbkx/${format}/${docname}" destfile="${project.build.directory}/docbkx/${format}/${docname}.zip"/>
+        <echo message="compressing ${format} from ${project.build.directory}/asciidoc/${format} to ${project.build.directory}/${project.name}-${format}.zip"/>
+        <zip basedir="${project.build.directory}/asciidoc/${format}" destfile="${project.build.directory}/${project.name}-${format}.zip"/>
     </target>
 </project>
\ No newline at end of file

--
Gitblit v1.10.0