|
43 | 43 | - name: Build and check image sizes |
44 | 44 | if: steps.changed-dockerfiles.outputs.files != '' |
45 | 45 | run: | |
46 | | - set -e |
| 46 | + set -x |
47 | 47 | merged_commit=$(git log -1 --format='%H') |
48 | | - echo "### Images size variations" >> $GITHUB_STEP_SUMMARY |
49 | 48 | while IFS= read -r -d '' dockerfile; do |
50 | 49 | [ -z "$dockerfile" ] && continue |
51 | 50 | dir=$(dirname "$dockerfile") |
|
73 | 72 | size_pr=$(docker image inspect "$image_pr" | jq '.[0].Size / (1024 * 1024) | round') |
74 | 73 |
|
75 | 74 | diff=$((size_pr - size_base)) |
76 | | - echo "::warning::Image size change: $size_base -> $size_pr MB' (diff: $diff MB)" |
77 | | - echo "File $dockerfile resulted in a change in the image size from $size_base -> $size_pr MB" >> $GITHUB_STEP_SUMMARY |
| 75 | + # echo "::warning::Image size change: $size_base -> $size_pr MB' (diff: $diff MB)" |
| 76 | + echo "comment to ${{ github.event.pull_request.number }}" |
| 77 | + if [ "$diff" -gt 50 ]; then |
| 78 | + curl -X POST \ |
| 79 | + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 80 | + -H "Accept: application/vnd.github.v3+json" \ |
| 81 | + "https://github.com/opea-project/GenAIExamples/issues/${{ github.event.pull_request.number }}/comments" \ |
| 82 | + -d '{"body":"⚠️ File $dockerfile resulted in a change in the image size from $size_base -> $size_pr MB"}' |
| 83 | + else |
| 84 | + curl -X POST \ |
| 85 | + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 86 | + -H "Accept: application/vnd.github.v3+json" \ |
| 87 | + "https://github.com/opea-project/GenAIExamples/issues/${{ github.event.pull_request.number }}/comments" \ |
| 88 | + -d '{"body":"File $dockerfile resulted in a change in the image size from $size_base -> $size_pr MB"}' |
| 89 | + fi |
| 90 | + |
| 91 | + # echo "File $dockerfile resulted in a change in the image size from $size_base -> $size_pr MB" >> $GITHUB_STEP_SUMMARY |
78 | 92 | docker rmi "$image_base" "$image_pr" |
79 | 93 | done < <(echo "${{ steps.changed-dockerfiles.outputs.files }}" | tr '\n' '\0') |
0 commit comments