Skip to content

Commit 2d36765

Browse files
committed
Ensure removing artifacts from the good branch
1 parent 65f38b9 commit 2d36765

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

.github/workflows/pr-cleanup.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,25 @@ jobs:
2121
run: |
2222
set -u
2323
24-
ARTIFACTS=$(
24+
ARTIFACTS=$( \
2525
gh api \
2626
--paginate \
2727
-H "Accept: application/vnd.github+json" \
2828
-H "X-GitHub-Api-Version: 2022-11-28" \
2929
/repos/probabl-ai/skore/actions/artifacts \
30-
|
31-
jq -c ".artifacts[] | select(.workflow_run.head_branch == \"${BRANCH}\") | {id: .id, name: .name}"
30+
| \
31+
jq -c " \
32+
.artifacts[] \
33+
| select((.workflow_run.head_branch == \"${HEAD_BRANCH}\") and (.workflow_run.head_repository_id == ${HEAD_REPOSITORY_ID})) \
34+
| {id: .id, name: .name} \
35+
" \
3236
)
3337
3438
for ARTIFACT in $ARTIFACTS; do
3539
ID=$(echo "${ARTIFACT}" | jq -r '.id')
3640
NAME=$(echo "${ARTIFACT}" | jq -r '.name')
3741
38-
echo "Deleting artifact (BRANCH: \"${BRANCH}\", NAME: \"${NAME}\", ID: \"${ID}\")"
42+
echo "Deleting artifact (NAME: \"${NAME}\", ID: \"${ID}\")"
3943
4044
gh api \
4145
--method DELETE \
@@ -48,7 +52,8 @@ jobs:
4852
GH_TOKEN: ${{ github.token }}
4953
REPOSITORY_OWNER: ${{ github.repository_owner }}
5054
REPOSITORY_NAME: ${{ github.event.repository.name }}
51-
BRANCH: ${{ github.head_ref }}
55+
HEAD_REPOSITORY_ID: ${{ github.event.pull_request.head.repo.id }}
56+
HEAD_BRANCH: ${{ github.head_ref }}
5257

5358
clean-documentation-preview:
5459
if: always()
@@ -67,7 +72,7 @@ jobs:
6772
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOC_PREVIEW }}
6873

6974
- name: Clean documentation preview
70-
run: rclone --config rclone.configuration purge "${PROVIDER}:${BUCKET}/${PULL_REQUEST_NUMBER}" -vvvv
75+
run: rclone --config rclone.configuration purge "${PROVIDER}:${BUCKET}/${PULL_REQUEST_NUMBER}"
7176
env:
7277
PROVIDER: scaleway
7378
BUCKET: ${{ vars.DOCUMENTATION_PREVIEW_BUCKET }}

0 commit comments

Comments
 (0)