From b7446f9d2d05323927f4c40634cac9c99e8718ed Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Wed, 1 Apr 2026 13:49:30 -0300 Subject: [PATCH] Describe skip label availability and add skip-specific comment --- changelog/README.md | 11 ++++++++--- changelog/submit/action.yml | 13 +++++++++++++ .../submit/scripts/post-failure-comment.js | 12 +++++++++++- .../submit/scripts/post-skipped-comment.js | 19 +++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 changelog/submit/scripts/post-skipped-comment.js diff --git a/changelog/README.md b/changelog/README.md index bf94d86..6e9c8ce 100644 --- a/changelog/README.md +++ b/changelog/README.md @@ -139,9 +139,12 @@ submit workflow (write permissions, via workflow_run) │ └── posts PR comment with view/edit links │ ├── if "no-label": - │ └── posts PR comment listing available labels + │ └── posts PR comment listing available type labels and skip labels │ - └── otherwise (skipped, manually-edited): no-op + ├── if "skipped" (label rules): + │ └── posts PR comment confirming changelog was skipped + │ + └── otherwise (manually-edited): no-op ``` The evaluate logic runs twice — once as a gate (with event-specific checks like body-only edit and bot-loop detection), and once in the trusted submit context to drive behavior. This is intentional: the second evaluation uses fresh PR data from the API, so it correctly handles label or title changes between the two runs. @@ -170,7 +173,9 @@ rules: exclude: "changelog:skip" ``` -When all products are blocked by the create rules, the validate action passes (so CI stays green) but the submit action detects the same condition and exits without generating. You can also use `include` mode or per-product overrides. See [Rules for creation and publishing](https://elastic.github.io/docs-builder/contribute/changelog/#rules-for-creation-and-publishing) for the full reference. +When all products are blocked by the create rules, the validate action passes (so CI stays green) and the submit action posts a comment confirming that changelog generation was skipped. You can also use `include` mode or per-product overrides. See [Rules for creation and publishing](https://elastic.github.io/docs-builder/contribute/changelog/#rules-for-creation-and-publishing) for the full reference. + +When a PR has no type label, the failure comment also lists the available skip labels (if configured), so contributors know how to opt out of changelog generation. ## Manual edits diff --git a/changelog/submit/action.yml b/changelog/submit/action.yml index fff2460..e7e5f11 100644 --- a/changelog/submit/action.yml +++ b/changelog/submit/action.yml @@ -251,9 +251,22 @@ runs: PR_NUMBER: ${{ steps.pr.outputs.number }} LABEL_TABLE: ${{ steps.evaluate.outputs.label-table }} PRODUCT_LABEL_TABLE: ${{ steps.evaluate.outputs.product-label-table }} + SKIP_LABELS: ${{ steps.evaluate.outputs.skip-labels }} CONFIG_FILE: ${{ inputs.config }} with: github-token: ${{ inputs.github-token }} script: | const script = require('${{ github.action_path }}/scripts/post-failure-comment.js'); await script({ github, context, core }); + + - name: Post skipped comment + if: steps.evaluate.outputs.status == 'skipped' + uses: actions/github-script@v8 + env: + PR_NUMBER: ${{ steps.pr.outputs.number }} + SKIP_LABELS: ${{ steps.evaluate.outputs.skip-labels }} + with: + github-token: ${{ inputs.github-token }} + script: | + const script = require('${{ github.action_path }}/scripts/post-skipped-comment.js'); + await script({ github, context, core }); diff --git a/changelog/submit/scripts/post-failure-comment.js b/changelog/submit/scripts/post-failure-comment.js index 7ac362b..f77fb32 100644 --- a/changelog/submit/scripts/post-failure-comment.js +++ b/changelog/submit/scripts/post-failure-comment.js @@ -5,6 +5,7 @@ module.exports = async ({ github, context, core }) => { const configFile = process.env.CONFIG_FILE || 'docs/changelog.yml'; const labelRows = process.env.LABEL_TABLE || ''; const productLabelRows = process.env.PRODUCT_LABEL_TABLE || ''; + const skipLabels = process.env.SKIP_LABELS || ''; let labelSection; if (labelRows.trim()) { @@ -28,14 +29,23 @@ module.exports = async ({ github, context, core }) => { ].join('\n'); } + let skipSection; + if (skipLabels.trim()) { + const formatted = skipLabels.split(',').map(l => `\`${l.trim()}\``).join(', '); + skipSection = `\n⏭️ To skip changelog generation, add one of these labels: ${formatted}`; + } else { + skipSection = `\n⏭️ No skip labels are configured. To allow skipping changelog generation, add a label to \`rules.create.exclude\` in \`${configFile}\`.`; + } + const body = [ TITLE, '', '⚠️ **Cannot generate changelog:** no matching type label found on this PR.', labelSection, productSection, + skipSection, '', - `🔖 To skip changelog generation or configure label rules, see \`${configFile}\`.`, + `📄 See \`${configFile}\` for the full changelog configuration.`, ].join('\n'); await upsertComment({ github, context, prNumber, body }); diff --git a/changelog/submit/scripts/post-skipped-comment.js b/changelog/submit/scripts/post-skipped-comment.js new file mode 100644 index 0000000..94d4433 --- /dev/null +++ b/changelog/submit/scripts/post-skipped-comment.js @@ -0,0 +1,19 @@ +const { TITLE, upsertComment } = require('./comment-helper'); + +module.exports = async ({ github, context, core }) => { + const prNumber = parseInt(process.env.PR_NUMBER, 10); + const skipLabels = process.env.SKIP_LABELS || ''; + + const bodyParts = [ + TITLE, + '', + '⏭️ Changelog generation was skipped for this pull request.', + ]; + + if (skipLabels.trim()) { + const formatted = skipLabels.split(',').map(l => `\`${l.trim()}\``).join(', '); + bodyParts.push('', `Matched skip label(s): ${formatted}`); + } + + await upsertComment({ github, context, prNumber, body: bodyParts.join('\n') }); +};