Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions changelog/submit/apply/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<!-- Generated by https://github.com/reakaleek/gh-action-readme -->
# <!--name-->Changelog submit / apply<!--/name-->
<!--description-->
Write action that downloads the changelog artifact produced by the evaluate action and either commits it to the PR branch or posts it as a PR comment. Requires contents:write and pull-requests:write permissions.
Write action that downloads the changelog artifact produced by the evaluate action, commits the changelog entry to the PR branch, and uploads a changelog-decision artifact for the downstream comment workflow. Requires contents:write and pull-requests:write permissions.
<!--/description-->

## Inputs
<!--inputs-->
| Name | Description | Required | Default |
|----------------|--------------------------------------------------------------------|----------|-----------------------|
| `github-token` | GitHub token with contents:write and pull-requests:write | `false` | `${{ github.token }}` |
| `config` | Path to changelog.yml configuration file (used in failure comment) | `false` | `docs/changelog.yml` |
| Name | Description | Required | Default |
|----------------|-----------------------------------------------------------|----------|-----------------------|
| `github-token` | GitHub token with contents:write and pull-requests:write | `false` | `${{ github.token }}` |
<!--/inputs-->

## Outputs
Expand Down
81 changes: 32 additions & 49 deletions changelog/submit/apply/action.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name: Changelog submit / apply
description: >
Write action that downloads the changelog artifact produced by the evaluate
action and either commits it to the PR branch or posts it as a PR comment.
action, commits the changelog entry to the PR branch, and uploads a
changelog-decision artifact for the downstream comment workflow.
Requires contents:write and pull-requests:write permissions.

inputs:
github-token:
description: 'GitHub token with contents:write and pull-requests:write'
default: '${{ github.token }}'
config:
description: 'Path to changelog.yml configuration file (used in failure comment)'
default: 'docs/changelog.yml'

outputs:
committed:
Expand Down Expand Up @@ -131,51 +129,36 @@ runs:
run: |
echo "::warning::Changelog commit step failed; posting the entry as a PR comment only. Same-repository PR entries are not regenerated by the merge-time upload, so resolve the commit failure before merging."

- name: Post success comment
if: steps.commit.outputs.committed == 'true'
uses: actions/github-script@v9
env:
PR_NUMBER: ${{ steps.meta.outputs.pr-number }}
HEAD_REF: ${{ steps.meta.outputs.head-ref }}
CHANGELOG_FILE: ${{ steps.commit.outputs.changelog-file }}
with:
github-token: ${{ inputs.github-token }}
script: |
const script = require('${{ github.action_path }}/scripts/post-success-comment.js');
await script({ github, context, core });

# Two paths arrive here:
# 1. The strategy chose comment-only (fork PR from a trusted author, or
# explicit `comment-only: true` input).
# 2. The strategy chose commit but the commit step failed; rather than
# hard-fail, expose the generated entry on the PR so reviewers and the
# author can still see what would have been recorded.
- name: Post comment-only changelog
if: steps.meta.outputs.should-comment-success == 'true' || steps.commit.outcome == 'failure'
uses: actions/github-script@v9
- name: Record decision and stage comment artifact
if: always()
continue-on-error: true
shell: bash
env:
PR_NUMBER: ${{ steps.meta.outputs.pr-number }}
CHANGELOG_DIR: ${{ steps.meta.outputs.changelog-dir }}
STAGING_DIR: /tmp/changelog-staging
IS_FORK: ${{ steps.meta.outputs.is-fork }}
COMMIT_FAILED: ${{ steps.commit.outcome == 'failure' }}
with:
github-token: ${{ inputs.github-token }}
script: |
const script = require('${{ github.action_path }}/scripts/post-comment-only.js');
await script({ github, context, core });
COMMIT_OUTCOME: ${{ steps.commit.outputs.committed == 'true' && 'committed' || steps.commit.outcome == 'failure' && 'failed' || 'none' }}
COMMITTED_FILE: ${{ steps.commit.outputs.changelog-file }}
run: |
mkdir -p .artifacts/changelog-decision
cp /tmp/changelog-staging/metadata.json .artifacts/changelog-decision/metadata.json

- name: Post failure comment
if: steps.meta.outputs.should-comment-failure == 'true'
uses: actions/github-script@v9
env:
PR_NUMBER: ${{ steps.meta.outputs.pr-number }}
LABEL_TABLE: ${{ steps.meta.outputs.label-table }}
PRODUCT_LABEL_TABLE: ${{ steps.meta.outputs.product-label-table }}
SKIP_LABELS: ${{ steps.meta.outputs.skip-labels }}
CONFIG_FILE: ${{ inputs.config }}
# Copy the generated YAML so the comment renderer can show it in comment-only mode
GENERATED=$(ls /tmp/changelog-staging/*.yaml 2>/dev/null | head -1)
if [ -n "$GENERATED" ]; then
cp "$GENERATED" .artifacts/changelog-decision/
fi

ARGS=(--metadata .artifacts/changelog-decision/metadata.json --commit-outcome "$COMMIT_OUTCOME")
if [ -n "$COMMITTED_FILE" ]; then
ARGS+=(--committed-file "$COMMITTED_FILE")
fi

docs-builder changelog github-decision "${ARGS[@]}"

- name: Upload decision artifact
if: always()
continue-on-error: true
uses: actions/upload-artifact@v7
with:
github-token: ${{ inputs.github-token }}
script: |
const script = require('${{ github.action_path }}/scripts/post-failure-comment.js');
await script({ github, context, core });
name: changelog-decision
path: .artifacts/changelog-decision
retention-days: 1
if-no-files-found: ignore
36 changes: 0 additions & 36 deletions changelog/submit/apply/scripts/comment-helper.js

This file was deleted.

39 changes: 0 additions & 39 deletions changelog/submit/apply/scripts/post-comment-only.js

This file was deleted.

54 changes: 0 additions & 54 deletions changelog/submit/apply/scripts/post-failure-comment.js

This file was deleted.

22 changes: 0 additions & 22 deletions changelog/submit/apply/scripts/post-success-comment.js

This file was deleted.

Loading