You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2021/06/21 11:13:19 UTC

[jena-site] branch enable-staging-publish created (now 45e8284)

This is an automated email from the ASF dual-hosted git repository.

rvesse pushed a change to branch enable-staging-publish
in repository https://gitbox.apache.org/repos/asf/jena-site.git.


      at 45e8284  Add staging stage to Jenkinsfile

This branch includes the following new commits:

     new 45e8284  Add staging stage to Jenkinsfile

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[jena-site] 01/01: Add staging stage to Jenkinsfile

Posted by rv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rvesse pushed a commit to branch enable-staging-publish
in repository https://gitbox.apache.org/repos/asf/jena-site.git

commit 45e8284ed0c0dd82cc4088beb89e9260180dd334
Author: Rob Vesse <rv...@dotnetrdf.org>
AuthorDate: Mon Jun 21 12:12:00 2021 +0100

    Add staging stage to Jenkinsfile
    
    This enables branches other than main to publish their changes to the
    staging branch automatically
---
 Jenkinsfile | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/Jenkinsfile b/Jenkinsfile
index dd5a2fa..32e6ebb 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -25,6 +25,7 @@ pipeline {
     environment {
         HUGO_VERSION = '0.66.0'
         DEPLOY_BRANCH = 'asf-site'
+        STAGING_BRANCH = 'staging'
     }
 
     stages {
@@ -61,6 +62,38 @@ pipeline {
                 }
             }
         }
+        stage('Staging') {
+            when {
+                 not {
+                     branch 'main'
+                 } 
+            }
+            steps {
+                    // Checkout branch with generated content
+                    sh """
+                        git checkout ${STAGING_BRANCH}
+                        git pull origin ${STAGING_BRANCH}
+                    """
+                    
+                    // Remove the content of the target branch and replace it with the content of the temp folder
+                    sh """
+                        rm -rf ${WORKSPACE}/content
+                        git rm -r --cached content/*
+                        mkdir -p ${WORKSPACE}/content
+                        cp -rT ${env.TMP_DIR}/* ${WORKSPACE}/content
+                    """
+                    
+                    // Commit the changes to the target branch
+                    env.COMMIT_MESSAGE = "Staged site from ${BRANCH_NAME} (${env.LAST_SHA})"
+                    sh """
+                        git add -A
+                        git commit -m "${env.COMMIT_MESSAGE}" | true
+                    """
+                    
+                    // Push the generated content for deployment
+                    sh "git push -u origin ${STAGING_BRANCH}"
+            }
+        }
         stage('Deploy') {
             when {
                 anyOf {