aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/news.yml
blob: a98c719c78222c2d51bccddd9dc081710bb8cfbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: "news.txt"
on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
    branches:
    - 'master'

permissions:
  contents: read

jobs:
  check:
    runs-on: ubuntu-latest
    if: >-
      github.event.pull_request.draft == false &&
      !contains(github.event.pull_request.labels.*.name, 'ci:skip-news') &&
      (
        (github.event.action != 'labeled' && github.event.action != 'unlabeled') ||
        github.event.label.name == 'ci:skip-news'
      )
    steps:
      - uses: actions/checkout@v7.0.1
        with:
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.sha }}
          persist-credentials: false
      - name: news.txt needs to be updated
        env:
          PULL_REQUEST_COMMITS: ${{ github.event.pull_request.commits }}
        run: |
          for commit in $(git rev-list "HEAD~${PULL_REQUEST_COMMITS}..HEAD"); do
            message=$(git log -n1 --pretty=format:%s $commit)
            type="$(echo "$message" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')"
            breaking="$(echo "$message" | sed -E 's|[[:alpha:]]+(\(.*\))?!:.*|breaking-change|')"
            if [[ "$type" == "feat" ]] || [[ "$type" == "perf" ]] || [[ "$breaking" == "breaking-change" ]]; then
              ! git diff "HEAD~${PULL_REQUEST_COMMITS}..HEAD" --quiet runtime/doc/news.txt runtime/doc/deprecated.txt ||
              {
                echo "
                  Pull request includes a new feature, performance improvement
                  or a breaking change, but news.txt hasn't been updated yet.
                  This is just a reminder that news.txt may need to be updated.
                  You can ignore this CI failure if you think the change won't
                  be of interest to users."
                  exit 1
               }
            fi
          done