Skip to content

ci: Test based on #1027 #12

ci: Test based on #1027

ci: Test based on #1027 #12

Workflow file for this run

name: cleanup PR
# on:
# pull_request_target:
# types: [closed]
on: [pull_request_target]
permissions: {}
defaults:
run:
shell: "bash"
jobs:
clean-artifacts:
if: always()
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Clean artifacts
run: |
set -u
ARTIFACTS=$(
gh api \
--paginate \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/probabl-ai/skore/actions/artifacts \
|
jq -c ".artifacts[] | select(.workflow_run.head_branch == \"${BRANCH}\") | {id: .id, name: .name}"
)
for ARTIFACT in $ARTIFACTS; do
ID=$(echo "${ARTIFACT}" | jq -r '.id')
NAME=$(echo "${ARTIFACT}" | jq -r '.name')
echo "Deleting artifact (BRANCH: \"${BRANCH}\", NAME: \"${NAME}\", ID: \"${ID}\")"
gh api \
--method DELETE \
--silent \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${REPOSITORY_OWNER}/${REPOSITORY_NAME}/actions/artifacts/${ID}
done
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY_OWNER: ${{ github.repository_owner }}
REPOSITORY_NAME: ${{ github.event.repository.name }}
BRANCH: ${{ github.head_ref }}
clean-documentation-preview:
if: always()
runs-on: ubuntu-latest
steps:
- name: Install `rclone`
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y rclone
- name: Copy configuration
shell: bash
run: echo "${CONFIGURATION}" > rclone.configuration
env:
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOC_PREVIEW }}
- name: Clean documentation preview
run: rclone --config rclone.configuration purge "${PROVIDER}:${BUCKET}/${PULL_REQUEST_NUMBER}" -vvvv
env:
PROVIDER: scaleway
BUCKET: ${{ vars.DOCUMENTATION_PREVIEW_BUCKET }}
PULL_REQUEST_NUMBER: 1027 # ${{ github.event.number }}