File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 - ' [0-9]+.[0-9]+-fr[0-9]+'
1212
1313permissions :
14+ contents : read
1415 pull-requests : write
1516
1617jobs :
@@ -20,17 +21,29 @@ jobs:
2021 - name : Checkout
2122 uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
2223 with :
23- ref : ${{ github.event.pull_request. head.sha || github.sha }}
24- allow-unsafe-pr-checkout : true
24+ # Never check out the untrusted PR head in this privileged workflow.
25+ ref : ${{ github.event.pull_request.base.sha || github.sha }}
2526
2627 - name : Install yq
2728 uses : mikefarah/yq@1b9b4ac5187171d2e5e3129be0cfa827c7f9d53d # v4
2829
2930 - name : Compute CRD JSON size
3031 id : size
32+ env :
33+ PR_HEAD_REPO : ${{ github.event.pull_request.head.repo.full_name }}
34+ PR_HEAD_SHA : ${{ github.event.pull_request.head.sha }}
3135 run : |
36+ set -euo pipefail
3237 CRD_FILE="config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml"
33- SIZE=$(yq eval -o=json "$CRD_FILE" | jq -c . | wc -c)
38+ if [ "$GITHUB_EVENT_NAME" = "pull_request_target" ]; then
39+ PR_CRD_JSON=$(gh api \
40+ -H "Accept: application/vnd.github.raw+json" \
41+ "repos/$PR_HEAD_REPO/contents/$CRD_FILE?ref=$PR_HEAD_SHA" \
42+ | yq eval -o=json - | jq -c .)
43+ SIZE=$(printf '%s\n' "$PR_CRD_JSON" | wc -c)
44+ else
45+ SIZE=$(yq eval -o=json "$CRD_FILE" | jq -c . | wc -c)
46+ fi
3447 echo "bytes=$SIZE" >> "$GITHUB_OUTPUT"
3548
3649 if [ "$SIZE" -lt 307200 ]; then
You can’t perform that action at this time.
0 commit comments