diff options
-rw-r--r-- | .github/workflows/hygiene.yml | 7 | ||||
-rwxr-xr-x | tools/ci/actions/check-changes-modified.sh | 16 |
2 files changed, 16 insertions, 7 deletions
diff --git a/.github/workflows/hygiene.yml b/.github/workflows/hygiene.yml index 7ae00a14c4..80d544d593 100644 --- a/.github/workflows/hygiene.yml +++ b/.github/workflows/hygiene.yml @@ -32,15 +32,16 @@ jobs: - name: Changes updated run: >- tools/ci/actions/check-changes-modified.sh + '${{ github.event.pull_request.issue_url }}' '${{ github.ref }}' 'pull_request' '${{ github.event.pull_request.base.ref }}' '${{ github.event.pull_request.base.sha }}' '${{ github.event.pull_request.head.ref }}' '${{ github.event.pull_request.head.sha }}' - if: >- - !contains(github.event.pull_request.labels.*.name, 'no-change-entry-needed') - && github.event_name == 'pull_request' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: github.event_name == 'pull_request' - name: configure correctly generated run: >- diff --git a/tools/ci/actions/check-changes-modified.sh b/tools/ci/actions/check-changes-modified.sh index e989e964b9..04c221c350 100755 --- a/tools/ci/actions/check-changes-modified.sh +++ b/tools/ci/actions/check-changes-modified.sh @@ -18,7 +18,12 @@ set -e # Hygiene Checks: check that Changes has been updated in PRs # One of the following must be true: # - A commit in the PR alters the Changes file -# - The no-change-entry-needed label is applied to the PR (handled in YAML) +# - The no-change-entry-needed label is applied to the PR + +API_URL="$1" +shift 1 + +AUTH="authorization: Bearer $GITHUB_TOKEN" # We need all the commits in the PR to be available . tools/ci/actions/deepen-fetch.sh @@ -26,8 +31,13 @@ set -e MSG='Check Changes has been updated' COMMIT_RANGE="$MERGE_BASE..$PR_HEAD" +LABEL='no-change-entry-needed' # Check if Changes has been updated in the PR -if git diff "$COMMIT_RANGE" --name-only --exit-code Changes > /dev/null; then +if ! git diff "$COMMIT_RANGE" --name-only --exit-code Changes > /dev/null; then + echo -e "$MSG: \e[32mYES\e[0m" +elif curl --silent --header "$AUTH" "$API_URL/labels" | grep -q "$LABEL"; then + echo -e "$MSG: \e[33mSKIP\e[0m" +else echo -e "$MSG: \e[31mNO\e[0m" cat <<"EOF" ------------------------------------------------------------------------ @@ -42,6 +52,4 @@ using the "no-change-entry-needed" label on the github pull request. ------------------------------------------------------------------------ EOF exit 1 -else - echo -e "$MSG: \e[32mYES\e[0m" fi |