Skip to content

Commit ed5bb99

Browse files
committed
ability to override watermark
1 parent c89678a commit ed5bb99

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/preview.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports.register = function () {
1818
const args = {
1919
repo: process.env.PREVIEW_REPO,
2020
branch: process.env.PREVIEW_BRANCH || 'HEAD',
21+
watermark_branch: process.env.PREVIEW_WATERMARK_BRANCH,
2122
config: process.env.PREVIEW_CONFIG || process.env.PREVIEW_BRANCH || 'HEAD',
2223
remote: process.env.PREVIEW_REMOTE ? true : false,
2324
repoPath: ((process.env.REPO_PATH || '..')
@@ -135,8 +136,9 @@ module.exports.register = function () {
135136
playbook.content.sources = mappedSources
136137

137138
const date = new Date().toISOString().split('T')[0]
139+
const watermark_branch = args.watermark || args.branch
138140
playbook.asciidoc.attributes['page-watermark'] =
139-
`${date} ${args.repo} ${args.branch}`
141+
`${date} ${args.repo} ${watermark_branch}`
140142

141143
// console.dir(playbook, {depth: 5}); process.exit(1)
142144
// reinflate .env before updating
@@ -187,8 +189,6 @@ function getSources(playbook, additionalSources) {
187189
return Object.fromEntries(sources)
188190
}
189191

190-
191-
192192
function overrideArray(_options) {
193193
return (_arr1, arr2) => arr2
194194
}
@@ -227,4 +227,4 @@ function spawn(...args) {
227227
}
228228
})
229229
})
230-
}
230+
}

scripts/preview

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ if [ -n "$REMOTE" ]; then
212212
assert "$PREVIEW_BRANCH" "$PREVIEW_CONFIG" "Remote preview doesn't support custom --config, will be ignored"
213213
assert "$DEBUG" "" "Remote preview doesn't support --debug, will be ignored"
214214

215+
PR_BASE_OID=$(gh pr view --json baseRefOid -q .baseRefOid 2>/dev/null) || true
216+
PR_BASE_NAME=$(gh pr view --json baseRefName -q .baseRefName 2>/dev/null) || true
217+
215218
WORKFLOW=preview-deploy.yml
216219
UUID=$(uuidgen)
217220

@@ -220,6 +223,8 @@ if [ -n "$REMOTE" ]; then
220223
--field preview_branch=${PREVIEW_BRANCH} \
221224
--field preview_start_path=${PREVIEW_START_PATH} \
222225
--field preview_override=${PREVIEW_OVERRIDE} \
226+
--field pr_base_name=${PR_BASE_NAME} \
227+
--field pr_base_oid=${PR_BASE_OID} \
223228
--field uuid=${UUID} \
224229
> /dev/null
225230

0 commit comments

Comments
 (0)