name: Prowler - Check Changelog on: pull_request: types: [opened, synchronize, reopened, labeled, unlabeled] jobs: check-changelog: if: contains(github.event.pull_request.labels.*.name, 'no-changelog') == false runs-on: ubuntu-latest permissions: id-token: write contents: read pull-requests: write env: MONITORED_FOLDERS: "api ui prowler" steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 - name: Get list of changed files id: changed_files run: | git fetch origin ${{ github.base_ref }} git diff --name-only origin/${{ github.base_ref }}...HEAD > changed_files.txt cat changed_files.txt - name: Check for folder changes and changelog presence id: check_folders run: | missing_changelogs="" for folder in $MONITORED_FOLDERS; do if grep -q "^${folder}/" changed_files.txt; then echo "Detected changes in ${folder}/" if ! grep -q "^${folder}/CHANGELOG.md$" changed_files.txt; then echo "No changelog update found for ${folder}/" missing_changelogs="${missing_changelogs}- \`${folder}\`\n" fi fi done echo "missing_changelogs<> $GITHUB_OUTPUT echo -e "${missing_changelogs}" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - name: Find existing changelog comment if: github.event.pull_request.head.repo.full_name == github.repository id: find_comment uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e #v3.1.0 with: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' body-includes: '' - name: Update PR comment with changelog status if: github.event.pull_request.head.repo.full_name == github.repository uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 with: issue-number: ${{ github.event.pull_request.number }} comment-id: ${{ steps.find_comment.outputs.comment-id }} edit-mode: replace body: | ${{ steps.check_folders.outputs.missing_changelogs != '' && format('⚠️ **Changes detected in the following folders without a corresponding update to the `CHANGELOG.md`:** {0} Please add an entry to the corresponding `CHANGELOG.md` file to maintain a clear history of changes.', steps.check_folders.outputs.missing_changelogs) || '✅ All necessary `CHANGELOG.md` files have been updated. Great job! 🎉' }} - name: Fail if changelog is missing if: steps.check_folders.outputs.missing_changelogs != '' run: | echo "ERROR: Missing changelog updates in some folders." exit 1