77
88permissions :
99 contents : read
10- pull-requests : write
1110
1211jobs :
1312 build :
3837 if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
3938 echo "Searching for PR from branch '${{ github.ref_name }}'..."
4039 PR_NUMBER=$(gh pr list --state open --head "${{ github.ref_name }}" --json number --jq '.[0].number // empty')
40+ if [ -z "$PR_NUMBER" ]; then
41+ echo "Not found in current repo, searching across forks..."
42+ PR_NUMBER=$(gh pr list --state open --json number,headRefName,headRepositoryOwner --jq ".[] | select(.headRefName == \"${{ github.ref_name }}\") | .number" | head -n1)
43+ fi
4144 else
4245 # For issue_comment, the PR number is in the event context
4346 PR_NUMBER=${{ github.event.issue.number }}
@@ -109,27 +112,57 @@ jobs:
109112 docker image pull --platform linux/arm64 localhost:5000/app-bricks/python-base:latest
110113 docker image pull --platform linux/arm64 localhost:5000/app-bricks/python-apps-base:latest
111114
115+ - name : Calculate image sizes
116+ id : sizes
117+ run : |
118+ SIZE1=$(docker images 'localhost:5000/app-bricks/python-base:latest' --format '{{.Size}}')
119+ SIZE2=$(docker images 'localhost:5000/app-bricks/python-apps-base:latest' --format '{{.Size}}')
120+ echo "python_base_size=$SIZE1" >> $GITHUB_OUTPUT
121+ echo "python_apps_base_size=$SIZE2" >> $GITHUB_OUTPUT
122+
112123 - name : Add image sizes to Job Summary
113124 run : |
114125 echo "## Docker Image Sizes" >> $GITHUB_STEP_SUMMARY
115126 echo "" >> $GITHUB_STEP_SUMMARY
116127 echo "| Image | Size |" >> $GITHUB_STEP_SUMMARY
117128 echo "|-------|------|" >> $GITHUB_STEP_SUMMARY
118- echo "| app-bricks/python-base | $(docker images 'localhost:5000/app-bricks/python-base:latest' --format '{{.Size}}') |" >> $GITHUB_STEP_SUMMARY
119- echo "| app-bricks/python-apps-base | $(docker images 'localhost:5000/app-bricks/python-apps-base:latest' --format '{{.Size}}') |" >> $GITHUB_STEP_SUMMARY
120-
129+ echo "| app-bricks/python-base | ${{ steps.sizes.outputs.python_base_size }} |" >> $GITHUB_STEP_SUMMARY
130+ echo "| app-bricks/python-apps-base | ${{ steps.sizes.outputs.python_apps_base_size }} |" >> $GITHUB_STEP_SUMMARY
131+ outputs :
132+ python_base_size : ${{ steps.sizes.outputs.python_base_size }}
133+ python_apps_base_size : ${{ steps.sizes.outputs.python_apps_base_size }}
134+ pr_number : ${{ steps.pr_info.outputs.pr_number }}
135+ comment-results :
136+ runs-on : ubuntu-latest
137+ needs : build
138+ if : needs.build.outputs.pr_number != ''
139+ permissions :
140+ pull-requests : write
141+ steps :
121142 - name : Comment on PR with image sizes
122- if : steps.pr_info.outputs.pr_number != ''
123143 env :
124144 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
125145 run : |
126- SIZE1=$(docker images 'localhost:5000/app-bricks/python-base:latest' --format '{{.Size}}')
127- SIZE2=$(docker images 'localhost:5000/app-bricks/python-apps-base:latest' --format '{{.Size}}')
128- gh pr comment ${{ steps.pr_info.outputs.pr_number }} --body-file - <<EOF
146+ gh pr comment ${{ needs.build.outputs.pr_number }} --repo ${{ github.repository }} --body-file - <<EOF
129147 ## Docker Image Sizes
130148
131149 | Image | Size |
132150 |-------|------|
133- | app-bricks/python-base | $SIZE1 |
134- | app-bricks/python-apps-base | $SIZE2 |
151+ | app-bricks/python-base | ${{ needs.build.outputs.python_base_size }} |
152+ | app-bricks/python-apps-base | ${{ needs.build.outputs.python_apps_base_size }} |
135153 EOF
154+ notify-no-pr :
155+ runs-on : ubuntu-latest
156+ needs : build
157+ if : needs.build.outputs.pr_number == ''
158+ permissions : {}
159+
160+ steps :
161+ - name : Notify to check Job Summary
162+ run : |
163+ echo "ℹ️ No PR found for this workflow run."
164+ echo "📊 Image sizes are available in the Job Summary of the 'build' job."
165+ echo ""
166+ echo "To view:"
167+ echo "1. Go to the 'build' job above"
168+ echo "2. Scroll to the bottom to see the Job Summary"
0 commit comments