CI: sync up with changes in packages repo
[feed/telephony.git] / .github / workflows / check-autorelease-deprecation.yml
1 name: Check autorelease deprecation
2
3 on:
4 pull_request_target:
5 types: [opened, synchronize, converted_to_draft, ready_for_review, edited]
6
7 jobs:
8 build:
9 name: Check autorelease deprecation
10 runs-on: ubuntu-latest
11 strategy:
12 fail-fast: false
13
14 permissions:
15 pull-requests: write
16
17 steps:
18 - uses: actions/checkout@v3
19 with:
20 ref: ${{ github.event.pull_request.head.sha }}
21 fetch-depth: 0
22
23 - name: Determine branch name
24 run: |
25 BRANCH="${GITHUB_BASE_REF#refs/heads/}"
26 echo "Building for $BRANCH"
27 echo "BRANCH=$BRANCH" >> $GITHUB_ENV
28
29 - name: Determine changed packages
30 run: |
31 RET=0
32
33 # only detect packages with changes
34 PKG_ROOTS=$(find . -name Makefile | \
35 grep -v ".*/src/Makefile" | \
36 sed -e 's@./\(.*\)/Makefile@\1/@')
37 CHANGES=$(git diff --diff-filter=d --name-only origin/$BRANCH...)
38
39 for ROOT in $PKG_ROOTS; do
40 for CHANGE in $CHANGES; do
41 if [[ "$CHANGE" == "$ROOT"* ]]; then
42 if grep -q '$(AUTORELEASE)' "$ROOT/Makefile"; then
43 CONTAINS_AUTORELEASE+="$ROOT"
44 fi
45 break
46 fi
47 done
48 done
49
50 if [ -n "$CONTAINS_AUTORELEASE" ]; then
51 RET=1
52 cat > "$GITHUB_WORKSPACE/pr_comment.md" << EOF
53 Please do no longer set *PKG_RELEASE* to *AUTORELEASE* as the
54 feature is deprecated. Please use an integer instead. Below is a
55 list of affected packages including correct *PKG_RELEASE*:
56
57 EOF
58 fi
59
60 for ROOT in $CONTAINS_AUTORELEASE; do
61 echo -n " - ${ROOT}Makefile: PKG_RELEASE:=" >> "$GITHUB_WORKSPACE/pr_comment.md"
62 last_bump="$(git log --pretty=format:'%h %s' "$ROOT" |
63 grep --max-count=1 -e ': [uU]pdate to ' -e ': [bB]ump to ' |
64 cut -f 1 -d ' ')"
65
66 if [ -n "$last_bump" ]; then
67 echo -n $(($(git rev-list --count "$last_bump..HEAD" "$ROOT") + 2)) >> "$GITHUB_WORKSPACE/pr_comment.md"
68 else
69 echo -n $(($(git rev-list --count HEAD "$ROOT") + 2)) >> "$GITHUB_WORKSPACE/pr_comment.md"
70 fi
71 echo >> "$GITHUB_WORKSPACE/pr_comment.md"
72 done
73
74 exit $RET
75
76 - name: Find Comment
77 uses: peter-evans/find-comment@v2
78 if: ${{ failure() }}
79 id: fc
80 with:
81 issue-number: ${{ github.event.pull_request.number }}
82 comment-author: 'github-actions[bot]'
83
84 - name: Create or update comment
85 uses: peter-evans/create-or-update-comment@v2
86 if: ${{ failure() }}
87 with:
88 comment-id: ${{ steps.fc.outputs.comment-id }}
89 issue-number: ${{ github.event.pull_request.number }}
90 body-file: 'pr_comment.md'
91 edit-mode: replace