|
| 1 | +name: API Changelog Check |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'codegen/aws-models/**' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + check-changelog: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-changelog') }} |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Get changed model files |
| 22 | + id: changed-models |
| 23 | + run: | |
| 24 | + changed_models=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- 'codegen/aws-models/*.json' | xargs -I {} basename {} .json) |
| 25 | + echo "models<<EOF" >> $GITHUB_OUTPUT |
| 26 | + echo "$changed_models" >> $GITHUB_OUTPUT |
| 27 | + echo "EOF" >> $GITHUB_OUTPUT |
| 28 | +
|
| 29 | + - name: Check for changelog entries |
| 30 | + run: | |
| 31 | + missing_changelogs="" |
| 32 | +
|
| 33 | + while IFS= read -r service; do |
| 34 | + [ -z "$service" ] && continue |
| 35 | +
|
| 36 | + changelog_dir="clients/aws-sdk-${service}/.changes/next-release" |
| 37 | +
|
| 38 | + if [ ! -d "$changelog_dir" ]; then |
| 39 | + missing_changelogs="${missing_changelogs}\n - ${service} (directory does not exist: ${changelog_dir})" |
| 40 | + continue |
| 41 | + fi |
| 42 | +
|
| 43 | + # Check if there are any files in the next-release directory |
| 44 | + file_count=$(find "$changelog_dir" -maxdepth 1 -type f | wc -l) |
| 45 | + if [ "$file_count" -eq 0 ]; then |
| 46 | + missing_changelogs="${missing_changelogs}\n - ${service} (no changelog entries in ${changelog_dir})" |
| 47 | + fi |
| 48 | + done <<< "${{ steps.changed-models.outputs.models }}" |
| 49 | +
|
| 50 | + if [ -n "$missing_changelogs" ]; then |
| 51 | + echo "::error::Missing changelog entries for the following services:${missing_changelogs}" |
| 52 | + echo "" |
| 53 | + echo "Please add a changelog entry in clients/aws-sdk-<service>/.changes/next-release/ for each modified model." |
| 54 | + exit 1 |
| 55 | + fi |
| 56 | +
|
| 57 | + echo "All modified models have corresponding changelog entries." |
0 commit comments