Skip to content

Commit

Permalink
Merge pull request #534 from axonivy/siteDeployV2
Browse files Browse the repository at this point in the history
Deploy github site using maven-scm-publish plugin 🏗️
  • Loading branch information
ivy-rew authored Nov 18, 2024
2 parents 47bcb84 + 64d4a6c commit cc4a37f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 36 deletions.
27 changes: 21 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ pipeline {
}

parameters {
booleanParam(name: 'skipGitHubSite',
description: 'If checked the plugin documentation on GitHub will NOT be updated',
defaultValue: true)

string(name: 'engineListUrl',
description: 'Engine to use for build',
defaultValue: 'https://product.ivyteam.io')
Expand All @@ -27,18 +23,37 @@ pipeline {
script {
setupGPGEnvironment()
withCredentials([string(credentialsId: 'gpg.password', variable: 'GPG_PWD')]) {
def phase = isReleaseOrMasterBranch() ? 'deploy site-deploy' : 'verify'
def phase = isReleaseOrMasterBranch() ? 'deploy' : 'verify'
maven cmd: "clean ${phase} " +
"-Dgpg.skip=false " +
"-Dgpg.project-build.password='${env.GPG_PWD}' " +
"-Dgithub.site.skip=${params.skipGitHubSite} " +
"-Divy.engine.list.url=${params.engineListUrl} " +
"-Dmaven.test.failure.ignore=true"
}
collectBuildArtifacts()
}
}
}
stage('deploy-site') {
when {
expression { isReleaseOrMasterBranch() }
}
steps {
script {
withEnv(['GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no']) {
sshagent(credentials: ['github-axonivy']) {
def branch = "pages_$BRANCH_NAME-$BUILD_NUMBER"
def message = "Update site (${env.BRANCH_NAME})"
sh """
git config --global user.name 'ivy-team'
git config --global user.email '[email protected]'
"""
maven cmd: "site site:stage scm-publish:publish-scm"
}
}
}
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions build/release/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pipeline {
sh "gh auth login --with-token < ${tokenFile}"
sh "gh pr create --title '${message}' --body '${message}' --head ${targetBranch} --base ${env.BRANCH_NAME}"
}
// publish site from 'mvn release' run
maven cmd: "site:stage scm-publish:publish-scm"
}
}
}
Expand Down
44 changes: 14 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<other.site.name>Stable</other.site.name>
<autoRelease>true</autoRelease>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<github.site.skip>true</github.site.skip>
</properties>

<distributionManagement>
Expand All @@ -63,6 +62,10 @@
<name>Sonatype Releases Repo</name>
<url>https://oss.sonatype.org/content/repositories/releases/</url>
</repository>
<site>
<id>github</id>
<url>scm:git:[email protected]:axonivy/project-build-plugin.git</url>
</site>
</distributionManagement>

<dependencies>
Expand Down Expand Up @@ -284,7 +287,10 @@
<id>gh-pages.redirect.page</id>
<configuration>
<target>
<copy todir="${project.build.directory}/site-redirect">
<move todir="${project.build.directory}/site/${site.path}/${pluginVersion.majorVersion}.${pluginVersion.minorVersion}" >
<fileset dir="${project.build.directory}/site" />
</move>
<copy todir="${project.build.directory}/site/${site.path}/" >
<fileset dir="src/site/gh/pages/" />
<filterset id="replaceProductAndVersion">
<filter token="version" value="${pluginVersion.majorVersion}.${pluginVersion.minorVersion}" />
Expand All @@ -296,34 +302,12 @@
</executions>
</plugin>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<executions>
<execution>
<id>deploy.mojo.description.to.github</id>
<goals><goal>site</goal></goals>
<phase>site-deploy</phase>
<configuration>
<message>update maven plugin mojo description</message>
<path>${site.path}/${pluginVersion.majorVersion}.${pluginVersion.minorVersion}</path>
</configuration>
</execution>
<execution>
<id>deploy.site.redirect.to.github</id>
<goals><goal>site</goal></goals>
<phase>site-deploy</phase>
<configuration>
<message>update maven plugin mojo redirect</message>
<path>${site.path}</path>
<outputDirectory>${project.build.directory}/site-redirect</outputDirectory>
</configuration>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-publish-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<server>github.ivy-team.oauth</server>
<merge>true</merge>
<skip>${github.site.skip}</skip>
<scmBranch>gh-pages</scmBranch>
<skipDeletedFiles>true</skipDeletedFiles>
</configuration>
</plugin>
</plugins>
Expand All @@ -349,7 +333,7 @@
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<releaseProfiles>release</releaseProfiles>
<goals>deploy site-deploy</goals>
<goals>deploy site</goals>
</configuration>
</plugin>
</plugins>
Expand Down

0 comments on commit cc4a37f

Please sign in to comment.