diff --git a/.github/actions-scripts/content-changes-table-comment.js b/.github/actions-scripts/content-changes-table-comment.js index 4aecea4709..32400b46c8 100755 --- a/.github/actions-scripts/content-changes-table-comment.js +++ b/.github/actions-scripts/content-changes-table-comment.js @@ -2,6 +2,7 @@ import * as github from '@actions/github' import { setOutput } from '@actions/core' +import got from 'got' import { getContents } from '../../script/helpers/git-utils.js' import parse from '../../lib/read-frontmatter.js' @@ -47,6 +48,13 @@ const articleFiles = files.filter( const lines = await Promise.all( articleFiles.map(async (file) => { + // Action triggered on PR and after preview env is deployed. Check health to determine if preview env is ready (healthy) + let appUrlIsHealthy = false + try { + const res = await got.head(`${APP_URL}/healthz`, { retry: { limit: 0 } }) + appUrlIsHealthy = res.statusCode === 200 + } catch (err) {} + const sourceUrl = file.blob_url const fileName = file.filename.slice(pathPrefix.length) const fileUrl = fileName.slice(0, fileName.lastIndexOf('.')) @@ -70,7 +78,8 @@ const lines = await Promise.all( const { data } = parse(fileContents) let contentCell = '' - let previewCell = '' + let previewCell = appUrlIsHealthy ? '' : '_Deployment pending..._' + let prodCell = '' if (file.status === 'added') contentCell = 'New file: ' @@ -98,12 +107,16 @@ const lines = await Promise.all( if (versions.toString() === nonEnterpriseDefaultVersion) { // omit version from fpt url - previewCell += `[${plan}](${APP_URL}/${fileUrl})
` + previewCell += appUrlIsHealthy ? `[${plan}](${APP_URL}/${fileUrl})
` : '' prodCell += `[${plan}](${PROD_URL}/${fileUrl})
` } else { // for non-versioned releases (ghae, ghec) use full url - previewCell += `[${plan}](${APP_URL}/${versions}/${fileUrl})
` + if (appUrlIsHealthy) { + previewCell += appUrlIsHealthy + ? `[${plan}](${APP_URL}/${versions}/${fileUrl})
` + : '' + } prodCell += `[${plan}](${PROD_URL}/${versions}/${fileUrl})
` } } else if (versions.length) { @@ -113,7 +126,9 @@ const lines = await Promise.all( prodCell += `${plan}@ ` versions.forEach((version) => { - previewCell += `[${version.split('@')[1]}](${APP_URL}/${version}/${fileUrl}) ` + previewCell += appUrlIsHealthy + ? `[${version.split('@')[1]}](${APP_URL}/${version}/${fileUrl}) ` + : '' prodCell += `[${version.split('@')[1]}](${PROD_URL}/${version}/${fileUrl}) ` }) previewCell += '
' diff --git a/.github/workflows/content-changes-table-comment.yml b/.github/workflows/content-changes-table-comment.yml index 51fa2ce095..355af58d08 100644 --- a/.github/workflows/content-changes-table-comment.yml +++ b/.github/workflows/content-changes-table-comment.yml @@ -5,6 +5,10 @@ name: Content Changes Table Comment # **Who does it impact**: docs-internal/docs maintainers and contributors on: + # Trigger this workflow after preview deployment runs + workflow_run: + workflows: + - Azure - Deploy Preview Environment workflow_dispatch: pull_request_target: @@ -40,7 +44,6 @@ jobs: filters: | filterContentDir: - 'content/**/*' - filterContentDir: needs: PR-Preview-Links if: ${{ needs.PR-Preview-Links.outputs.filterContentDir == 'true' }}