Skip to content

Commit 9a975ca

Browse files
committed
[skip ci] Fix
1 parent 65f38b9 commit 9a975ca

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

.github/workflows/pr-cleanup.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: cleanup PR
22

3-
on:
4-
pull_request_target:
5-
types: [closed]
3+
# on:
4+
# pull_request_target:
5+
# types: [closed]
6+
7+
on: [pull_request_target]
68

79
permissions: {}
810

@@ -21,21 +23,25 @@ jobs:
2123
run: |
2224
set -u
2325
24-
ARTIFACTS=$(
26+
ARTIFACTS=$( \
2527
gh api \
2628
--paginate \
2729
-H "Accept: application/vnd.github+json" \
2830
-H "X-GitHub-Api-Version: 2022-11-28" \
2931
/repos/probabl-ai/skore/actions/artifacts \
30-
|
31-
jq -c ".artifacts[] | select(.workflow_run.head_branch == \"${BRANCH}\") | {id: .id, name: .name}"
32+
| \
33+
jq -c " \
34+
.artifacts[] \
35+
| select((.workflow_run.head_branch == \"${HEAD_BRANCH}\") and (.workflow_run.head_repository_id == \"${HEAD_REPOSITORY_ID}\")) \
36+
| {id: .id, name: .name} \
37+
" \
3238
)
3339
3440
for ARTIFACT in $ARTIFACTS; do
3541
ID=$(echo "${ARTIFACT}" | jq -r '.id')
3642
NAME=$(echo "${ARTIFACT}" | jq -r '.name')
3743
38-
echo "Deleting artifact (BRANCH: \"${BRANCH}\", NAME: \"${NAME}\", ID: \"${ID}\")"
44+
echo "Deleting artifact (HEAD BRANCH: \"${HEAD_BRANCH}\", NAME: \"${NAME}\", ID: \"${ID}\")"
3945
4046
gh api \
4147
--method DELETE \
@@ -48,7 +54,8 @@ jobs:
4854
GH_TOKEN: ${{ github.token }}
4955
REPOSITORY_OWNER: ${{ github.repository_owner }}
5056
REPOSITORY_NAME: ${{ github.event.repository.name }}
51-
BRANCH: ${{ github.head_ref }}
57+
HEAD_REPOSITORY_ID: ${{ github.event.pull_request.head.repo.id }}
58+
HEAD_BRANCH: ${{ github.head_ref }}
5259

5360
clean-documentation-preview:
5461
if: always()

0 commit comments

Comments
 (0)