@@ -36,42 +36,22 @@ jobs:
3636 run : |
3737 if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
3838 echo "Searching for PR from branch '${{ github.ref_name }}'..."
39- UPSTREAM_REPO=$(gh api repos/${{ github.repository }} --jq '.parent.full_name // empty')
40-
41- if [ -n "$UPSTREAM_REPO" ]; then
42- echo "This is a fork. Upstream repository: $UPSTREAM_REPO"
43- # Get current repo owner and branch
44- CURRENT_USER=$(gh api repos/${{ github.repository }} --jq '.owner.login')
45- BRANCH_NAME="${{ github.ref_name }}"
46- echo "Searching in upstream for PR from $CURRENT_USER:$BRANCH_NAME"
47-
48- # Use API to search for PR with matching head
49- PR_NUMBER=$(gh api "repos/$UPSTREAM_REPO/pulls?state=open&head=$CURRENT_USER:$BRANCH_NAME" --jq '.[0].number // empty')
50-
51- if [ -z "$PR_NUMBER" ]; then
52- echo "Not found with API, trying gh pr list..."
53- PR_NUMBER=$(gh pr list --repo "$UPSTREAM_REPO" --state open --json number,headRefName,headRepositoryOwner \
54- --jq ".[] | select(.headRefName == \"$BRANCH_NAME\" and .headRepositoryOwner.login == \"$CURRENT_USER\") | .number")
55- fi
56- TARGET_REPO="$UPSTREAM_REPO"
57- else
58- echo "This is not a fork. Searching in current repo..."
59- PR_NUMBER=$(gh pr list --state open --head "${{ github.ref_name }}" --json number --jq '.[0].number // empty')
60- TARGET_REPO="${{ github.repository }}"
39+ 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)
6143 fi
6244 else
6345 # For issue_comment, the PR number is in the event context
6446 PR_NUMBER=${{ github.event.issue.number }}
65- TARGET_REPO="${{ github.repository }}"
6647 fi
6748
6849 if [ -z "$PR_NUMBER" ]; then
6950 echo "Could not find an associated open pull request."
7051 else
71- echo "Found PR #$PR_NUMBER in repo $TARGET_REPO "
52+ echo "Found PR #$PR_NUMBER"
7253 fi
7354 echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
74- echo "target_repo=$TARGET_REPO" >> $GITHUB_OUTPUT
7555
7656 - name : Checkout PR Branch (for comment trigger)
7757 if : github.event_name == 'issue_comment'
@@ -146,13 +126,12 @@ jobs:
146126 echo "" >> $GITHUB_STEP_SUMMARY
147127 echo "| Image | Size |" >> $GITHUB_STEP_SUMMARY
148128 echo "|-------|------|" >> $GITHUB_STEP_SUMMARY
149- echo "| app-bricks/python-base | $(docker images 'localhost:5000/app-bricks/python-base:latest' --format '{{.Size}}') |" >> $GITHUB_STEP_SUMMARY
150- echo "| app-bricks/python-apps-base | $(docker images 'localhost:5000/app-bricks/python-apps-base:latest' --format '{{.Size}}') |" >> $GITHUB_STEP_SUMMARY
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
151131 outputs :
152132 python_base_size : ${{ steps.sizes.outputs.python_base_size }}
153133 python_apps_base_size : ${{ steps.sizes.outputs.python_apps_base_size }}
154134 pr_number : ${{ steps.pr_info.outputs.pr_number }}
155- target_repo : ${{ steps.pr_info.outputs.target_repo }}
156135 comment-results :
157136 runs-on : ubuntu-latest
158137 needs : build
@@ -164,18 +143,26 @@ jobs:
164143 env :
165144 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
166145 run : |
167- if gh pr comment ${{ needs.build.outputs.pr_number }} --repo " ${{ needs.build.outputs.target_repo }}" --body-file - <<EOF
146+ gh pr comment ${{ needs.build.outputs.pr_number }} --repo ${{ github.repository }} --body-file - <<EOF
168147 ## Docker Image Sizes
169148
170149 | Image | Size |
171150 |-------|------|
172151 | app-bricks/python-base | ${{ needs.build.outputs.python_base_size }} |
173152 | app-bricks/python-apps-base | ${{ needs.build.outputs.python_apps_base_size }} |
174153 EOF
175- then
176- echo "✅ Comment posted successfully"
177- else
178- echo "⚠️ Could not post comment (likely permission issue for cross-repo commenting)"
179- echo "Image sizes are available in the job summary of the build-images job"
180- exit 0
181- fi
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