diff --git a/.github/workflows/check-backport-changelog.yml b/.github/workflows/check-backport-changelog.yml new file mode 100644 index 0000000000000..939b86c00aca0 --- /dev/null +++ b/.github/workflows/check-backport-changelog.yml @@ -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 diff --git a/backport-changelog.md b/backport-changelog.md new file mode 100644 index 0000000000000..682dc2e670277 --- /dev/null +++ b/backport-changelog.md @@ -0,0 +1,5 @@ +# Core Backport Changelog + +Any PR that makes changes to be backported should log a core PR here. + +## 6.6 \ No newline at end of file