From 868f3b7c644e9337c78741c6be03c53e31f99135 Mon Sep 17 00:00:00 2001 From: ramon Date: Mon, 20 May 2024 15:30:44 -0700 Subject: [PATCH] Action --- .../workflows/check-components-changelog.yml | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/.github/workflows/check-components-changelog.yml b/.github/workflows/check-components-changelog.yml index b9d633fbcbe768..311266d6cdc923 100644 --- a/.github/workflows/check-components-changelog.yml +++ b/.github/workflows/check-components-changelog.yml @@ -16,7 +16,6 @@ jobs: check: name: Check CHANGELOG diff runs-on: ubuntu-latest - if: ! contains( github.event.pull_request.labels.*.name, 'No Core sync required') steps: - name: 'Get PR commit count' run: echo "PR_COMMIT_COUNT=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}" @@ -33,35 +32,38 @@ jobs: env: PR_NUMBER: ${{ github.event.number }} run: | - changelog_path="packages/components/CHANGELOG.md" - optional_check_notice="This isn't a required check, so if you think your changes are small enough that they don't warrant a CHANGELOG entry, please go ahead and merge without one." + # Check if the PR has the 'No Core sync required' label. If it does, skip the check. + if ! contains( github.event.pull_request.labels.*.name, 'No Core sync required'); then + changelog_path="packages/components/CHANGELOG.md" + optional_check_notice="This isn't a required check, so if you think your changes are small enough that they don't warrant a CHANGELOG entry, please go ahead and merge without one." - # 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 CHANGELOG entry to $changelog_path" - echo - echo "${optional_check_notice}" - exit 1 - fi + # 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 CHANGELOG entry to $changelog_path" + echo + echo "${optional_check_notice}" + exit 1 + fi - pr_link_pattern="\[#${PR_NUMBER}\]\(https://github\.com/WordPress/gutenberg/pull/${PR_NUMBER}\)" - pr_link_grep_pattern="\[#${PR_NUMBER}\](https://github\.com/WordPress/gutenberg/pull/${PR_NUMBER})" + pr_link_pattern="\[#${PR_NUMBER}\]\(https://github\.com/WordPress/gutenberg/pull/${PR_NUMBER}\)" + pr_link_grep_pattern="\[#${PR_NUMBER}\](https://github\.com/WordPress/gutenberg/pull/${PR_NUMBER})" - unreleased_section=$(sed -n '/^## Unreleased$/,/^## /p' "${changelog_path}") + unreleased_section=$(sed -n '/^## Unreleased$/,/^## /p' "${changelog_path}") - # 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 CHANGELOG entry to $changelog_path, and make sure your CHANGELOG entry has a link to the current PR." - echo - echo "${optional_check_notice}" - exit 1 - fi + # 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 CHANGELOG entry to $changelog_path, and make sure your CHANGELOG entry has a link to the current PR." + echo + echo "${optional_check_notice}" + exit 1 + fi - # Confirm that there is an 'Unreleased' section and that the relevant entry is in that section - if ! grep -nq -e '^## Unreleased' "${changelog_path}" || \ - ! [[ $unreleased_section = *${pr_link_pattern}* ]]; then - echo "Please make sure your CHANGELOG entry is in the \`## Unreleased\` section" - echo - echo "${optional_check_notice}" - exit 1 + # Confirm that there is an 'Unreleased' section and that the relevant entry is in that section + if ! grep -nq -e '^## Unreleased' "${changelog_path}" || \ + ! [[ $unreleased_section = *${pr_link_pattern}* ]]; then + echo "Please make sure your CHANGELOG entry is in the \`## Unreleased\` section" + echo + echo "${optional_check_notice}" + exit 1 + fi fi