diff --git a/.github/preview-index/src/indexFull.js b/.github/preview-index/src/indexFull.js index 22a94203..954f6a51 100644 --- a/.github/preview-index/src/indexFull.js +++ b/.github/preview-index/src/indexFull.js @@ -16,7 +16,7 @@ ************************************************************************* */ const fetch = require('node-fetch-commonjs'); -const { getConfig, getResourceIndexData, getItemId, sharepointHeaders, edsAdminHeaders } = require('./sharepoint'); +const { getConfig, getResourceIndexData, getItemId, sharepointHeaders, edsAdminHeaders, previewIndex } = require('./sharepoint'); const config = getConfig(); @@ -141,16 +141,7 @@ const reindex = async () => { console.log(`Failed to add index rows: ${response.status} - ${response.statusText}`); } - console.log('preview update url:' + config.PREVIEW_UPDATE_URL); - const previewResponse = await fetch(config.PREVIEW_UPDATE_URL, { - method: 'POST', - headers: edsAdminHeaders(), - }); - if (previewResponse?.ok) { - console.log(`Previewed index file: ${previewResponse.status} - ${previewResponse.statusText}`); - } else { - console.log(`Failed to preview index file: ${previewResponse.status} - ${previewResponse.statusText}`); - } + await previewIndex(); console.log(`Reindexed folder ${folder}`); }; diff --git a/.github/preview-index/src/indexSingle.js b/.github/preview-index/src/indexSingle.js index faf9eb5d..2ea5b3a1 100644 --- a/.github/preview-index/src/indexSingle.js +++ b/.github/preview-index/src/indexSingle.js @@ -16,7 +16,7 @@ ************************************************************************* */ const fetch = require('node-fetch-commonjs'); -const { getConfig, getResourceIndexData, getAccessToken, getItemId, sharepointHeaders } = require('./sharepoint'); +const { getConfig, getResourceIndexData, getAccessToken, getItemId, sharepointHeaders, previewIndex } = require('./sharepoint'); const config = getConfig(); @@ -186,6 +186,7 @@ const reindex = async () => { await addTableRow(itemId, resData); } + await previewIndex(); } reindex(); diff --git a/.github/preview-index/src/sharepoint.js b/.github/preview-index/src/sharepoint.js index fc11ae9c..8d2ffc87 100644 --- a/.github/preview-index/src/sharepoint.js +++ b/.github/preview-index/src/sharepoint.js @@ -195,11 +195,25 @@ const getItemId = async (indexPath) => { return null; }; +const previewIndex = async () => { + console.log('Preview update url: ' + PREVIEW_UPDATE_URL); + const previewResponse = await fetch(PREVIEW_UPDATE_URL, { + method: 'POST', + headers: edsAdminHeaders(), + }); + if (previewResponse?.ok) { + console.log(`Previewed index file: ${previewResponse.status} - ${previewResponse.statusText}`); + } else { + console.log(`Failed to preview index file: ${previewResponse.status} - ${previewResponse.statusText}`); + } +} + module.exports = { getConfig, getResourceIndexData, getAccessToken, getItemId, sharepointHeaders, - edsAdminHeaders + edsAdminHeaders, + previewIndex };