Skip to content

Add a workflow that generates a commit message. #7

Add a workflow that generates a commit message.

Add a workflow that generates a commit message. #7

# Generates a list of changes and a commit message when the pinned gutenberg repository hash changes.
name: Draft commit message
on:
# This workflow was introduced in WordPress 7.0.
pull_request:
branches:
- trunk
- '[7-9].[0-9]'
paths:
- 'package.json'
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}
jobs:
# Detects whether the gutenberg.sha value in the package.json file has changed.
detect-hash-change:
name: Detect Gutenberg SHA change
uses: ./.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml
permissions:
contents: read
# Generates a list of changes between two specified hashes.
generate-changelog:
name: Generate a list of changes between the hashes
uses: ./.github/workflows/reusable-generate-gutenberg-changelog-v1.yml
needs: [ 'detect-hash-change' ]
if: ${{ needs.detect-hash-change.outputs.sha_changed == 'true' }}
permissions:
contents: read
with:
base-sha: ${{ needs.detect-hash-change.outputs.base_sha }}
head-sha: ${{ needs.detect-hash-change.outputs.head_sha }}
# Drafts a commit message containing a detailed list of changes being merged.
#
# Performs the following steps:
# - Downloads the changelog artifact.
# - Builds a commit message.
# - Uploads the commit message as an artifact.
generate-commit-message:
name: Generate commit message
uses: ./.github/workflows/reusable-generate-commit-message-v1.yml
needs: [ 'detect-hash-change', 'generate-changelog' ]
if: ${{ needs.generate-changelog.outputs.has_changes == 'true' }}
permissions:
contents: read
with:
previous-hash: ${{ needs.detect-hash-change.outputs.base_sha }}
new-hash: ${{ needs.detect-hash-change.outputs.head_sha }}