mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-04 16:22:52 +08:00
ci: Add check for modification of changelog
This commit is contained in:
33
.github/workflows/build.yml
vendored
33
.github/workflows/build.yml
vendored
@@ -59,12 +59,45 @@ jobs:
|
||||
checks:
|
||||
runs-on: ubuntu-22.04
|
||||
needs: preBuild
|
||||
permissions:
|
||||
pull-requests: read
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
- name: Check for CHANGELOG or no-changelog label
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -e
|
||||
|
||||
BASE_SHA="${{ github.event.pull_request.base.sha }}"
|
||||
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
|
||||
|
||||
echo "Checking changed files..."
|
||||
|
||||
if git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -qx "CHANGELOG.md"; then
|
||||
echo "✅ CHANGELOG.md was modified."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "CHANGELOG.md not modified. Checking labels..."
|
||||
|
||||
LABELS=$(gh api \
|
||||
repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
|
||||
--jq '.[].name')
|
||||
|
||||
if echo "$LABELS" | grep -qx "no-changelog"; then
|
||||
echo "✅ no-changelog label found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "::error::This PR must either modify CHANGELOG.md or have the 'no-changelog' label."
|
||||
exit 1
|
||||
- name: Install gitlint
|
||||
run: |
|
||||
pip install gitlint==0.19.1
|
||||
|
||||
Reference in New Issue
Block a user