Skip to content

Commit

Permalink
Workflows: try a backport changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 20, 2024
1 parent e7bb3df commit 4d1bb0c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/check-backport-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Verify Core Backport Changlog

on:
pull_request:
types: [opened, synchronize]
paths:
- 'lib/**'
- 'packages/**/*.php'
- 'phpunit/**'
jobs:
check:
name: Check CHANGELOG diff
runs-on: ubuntu-latest
steps:
- name: 'Get PR commit count'
run: echo "PR_COMMIT_COUNT=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
- name: Checkout code
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: ${{ env.PR_COMMIT_COUNT }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: 'Fetch relevant history from origin'
run: git fetch origin ${{ github.event.pull_request.base.ref }}
- name: Check CHANGELOG status
env:
PR_NUMBER: ${{ github.event.number }}
run: |
changelog_path="backport-changelog.md"
# Fail if the PR doesn't touch the changelog
if git diff --quiet ${{ github.event.pull_request.base.sha }} HEAD -- "$changelog_path"; then
echo "Please add a CORE PR LINK (in Markdown) to $changelog_path"
echo "If changes are related to an existing, open PR, you may use that PR"
exit 1
fi
pr_link_grep_pattern="https://github\.com/WordPress/gutenberg/pull/\([0-9]\+\) for https://github\.com/WordPress/gutenberg/pull/${PR_NUMBER}"
# Confirm that the CHANGELOG has an entry for the current PR
if ! grep -nq -e "${pr_link_grep_pattern}" "${changelog_path}"; then
echo "Please add a CORE PR LINK to $changelog_path. Make sure it is linked in Markdown."
echo "If changes are related to an existing, open PR, you may use that PR"
exit 1
fi
5 changes: 5 additions & 0 deletions backport-changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Core Backport Changelog

Any PR that makes changes to be backported should log a core PR here.

## 6.6

0 comments on commit 4d1bb0c

Please sign in to comment.