diff --git a/.github/workflows/cleanup-playground-artifacts.yml b/.github/workflows/cleanup-playground-artifacts.yml new file mode 100644 index 0000000..2b8c9d1 --- /dev/null +++ b/.github/workflows/cleanup-playground-artifacts.yml @@ -0,0 +1,25 @@ +name: Cleanup WordPress Playground PR Artifacts + +on: + pull_request: + types: [closed] + +permissions: + contents: write + +jobs: + cleanup-artifacts: + name: Cleanup PR Artifacts + runs-on: ubuntu-24.04 + steps: + - name: Cleanup PR artifacts from release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + assets=$(gh release view ci-artifacts --repo ${{ github.repository }} --json assets -q ".assets[].name" 2>/dev/null || echo "") + for asset in $assets; do + if [[ "$asset" == "pr-${{ github.event.pull_request.number }}-"* ]]; then + echo "Deleting $asset..." + gh release delete-asset ci-artifacts "$asset" --repo ${{ github.repository }} -y || true + fi + done diff --git a/.github/workflows/reusable-wp-playground-pr-preview-public.yml b/.github/workflows/reusable-wp-playground-pr-preview-public.yml index 6b6d71e..58a3cb2 100644 --- a/.github/workflows/reusable-wp-playground-pr-preview-public.yml +++ b/.github/workflows/reusable-wp-playground-pr-preview-public.yml @@ -21,7 +21,7 @@ on: description: 'Number of artifacts to keep per PR' required: false type: string - default: '2' + default: '1' permissions: {} diff --git a/.github/workflows/reusable-wp-playground-pr-preview.yml b/.github/workflows/reusable-wp-playground-pr-preview.yml index 0ddf6ed..43b8ee1 100644 --- a/.github/workflows/reusable-wp-playground-pr-preview.yml +++ b/.github/workflows/reusable-wp-playground-pr-preview.yml @@ -21,7 +21,7 @@ on: description: 'Number of artifacts to keep per PR' required: false type: string - default: '2' + default: '1' permissions: contents: read