From 4be435cf65d110e1086922f46269e994ccfbd2e2 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 28 May 2026 15:34:45 +0000 Subject: [PATCH 1/2] fix: update playground pr preview and cleanup artifacts - Set artifacts-to-keep to 1 to replace old artifacts on new commits - Create reusable cleanup workflows to delete artifacts from ci-artifacts - Update caller workflows to run cleanup job on pull request closed events --- .github/workflows/ci.yml | 14 ++++- .../reusable-cleanup-pr-artifacts-public.yml | 30 ++++++++++ .../reusable-cleanup-pr-artifacts.yml | 55 +++++++++++++++++++ ...usable-wp-playground-pr-preview-public.yml | 2 +- .../reusable-wp-playground-pr-preview.yml | 2 +- .github/workflows/test-private-workflows.yml | 14 ++++- .github/workflows/test-public-workflows.yml | 14 ++++- 7 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/reusable-cleanup-pr-artifacts-public.yml create mode 100644 .github/workflows/reusable-cleanup-pr-artifacts.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 312469f..9d5c546 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: branches: - main - release/** - types: [opened, synchronize, reopened, ready_for_review] + types: [opened, synchronize, reopened, ready_for_review, closed] workflow_dispatch: concurrency: @@ -22,7 +22,7 @@ jobs: detect: name: Detect Changes runs-on: ubuntu-latest - if: github.event_name != 'pull_request' || github.event.pull_request.draft == false + if: (github.event_name != 'pull_request' || github.event.pull_request.draft == false) && github.event.action != 'closed' permissions: contents: read pull-requests: read @@ -186,6 +186,7 @@ jobs: build-plugin-zip: name: Build Plugin Zip + if: github.event_name != 'pull_request' || github.event.action != 'closed' permissions: contents: read uses: ./.github/workflows/reusable-build-public.yml @@ -209,3 +210,12 @@ jobs: run-id: ${{ github.run_id }} artifact-prefix: 'plugin-skeleton-d-pr' artifact-filename: 'plugin-skeleton-d.zip' + + cleanup-pr-artifacts: + name: Cleanup PR Artifacts + if: github.event_name == 'pull_request' && github.event.action == 'closed' + uses: ./.github/workflows/reusable-cleanup-pr-artifacts-public.yml + permissions: + contents: write + with: + pr-number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/reusable-cleanup-pr-artifacts-public.yml b/.github/workflows/reusable-cleanup-pr-artifacts-public.yml new file mode 100644 index 0000000..043865c --- /dev/null +++ b/.github/workflows/reusable-cleanup-pr-artifacts-public.yml @@ -0,0 +1,30 @@ +name: Cleanup WordPress Playground PR Artifacts + +on: + workflow_call: + inputs: + pr-number: + description: 'The pull request number' + required: true + type: string + +permissions: {} + +jobs: + cleanup-artifacts: + name: Cleanup PR Artifacts + runs-on: ubuntu-24.04 + permissions: + contents: write + 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-${{ inputs.pr-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-cleanup-pr-artifacts.yml b/.github/workflows/reusable-cleanup-pr-artifacts.yml new file mode 100644 index 0000000..e180419 --- /dev/null +++ b/.github/workflows/reusable-cleanup-pr-artifacts.yml @@ -0,0 +1,55 @@ +name: Cleanup WordPress Playground PR Artifacts + +on: + workflow_call: + inputs: + pr-number: + description: 'The pull request number' + required: true + type: string + +permissions: {} + +jobs: + cleanup-artifacts: + name: Cleanup PR Artifacts + runs-on: [public-repo] + container: + image: ghcr.io/actions/actions-runner@sha256:1ad983536759ceec39ed75a2c8f007ca8c37b66eee35ed86f13623b29a4db97d # v2.333.0 + permissions: + contents: write + steps: + - name: Install GH cli + run: | + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null + sudo apt-get update + sudo apt install -y gh + + - 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-${{ inputs.pr-number }}-"* ]]; then + echo "Deleting $asset..." + gh release delete-asset ci-artifacts "$asset" --repo ${{ github.repository }} -y || true + fi + done + + - name: Cleanup Workspace & Home to avoid pollution + if: always() + run: | + # Wipes the actual code, build artifacts, and hidden files + sudo rm -rf ./* .[!.]* 2>/dev/null || true + + # Deletes everything inside _temp EXCEPT the locked mount points + sudo find /__w/_temp/ -mindepth 1 -maxdepth 1 ! -name '_github_home' ! -name '_github_workflow' -exec rm -rf {} + + + # Empties the contents of the locked directories without deleting the folders themselves + sudo rm -rf /github/home/* || true + sudo rm -rf /github/home/.* 2>/dev/null || true + + sudo rm -rf /github/workflow/* || true + sudo rm -rf /github/workflow/.* 2>/dev/null || true 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 diff --git a/.github/workflows/test-private-workflows.yml b/.github/workflows/test-private-workflows.yml index 2bbc164..ee62334 100644 --- a/.github/workflows/test-private-workflows.yml +++ b/.github/workflows/test-private-workflows.yml @@ -10,7 +10,7 @@ on: branches: - main - release/** - types: [opened, synchronize, reopened, ready_for_review] + types: [opened, synchronize, reopened, ready_for_review, closed] workflow_dispatch: concurrency: @@ -24,7 +24,7 @@ jobs: detect: name: Detect Changes runs-on: ubuntu-24.04 - if: github.event_name != 'pull_request' || github.event.pull_request.draft == false + if: (github.event_name != 'pull_request' || github.event.pull_request.draft == false) && github.event.action != 'closed' permissions: contents: read pull-requests: read @@ -157,6 +157,7 @@ jobs: build-plugin-zip: name: Build Plugin Zip + if: github.event_name != 'pull_request' || github.event.action != 'closed' permissions: contents: read uses: ./.github/workflows/reusable-build.yml @@ -179,3 +180,12 @@ jobs: run-id: ${{ github.run_id }} artifact-prefix: 'plugin-skeleton-d-pr-private' artifact-filename: 'plugin-skeleton-d.zip' + + cleanup-pr-artifacts: + name: Cleanup PR Artifacts + if: github.event_name == 'pull_request' && github.event.action == 'closed' + uses: ./.github/workflows/reusable-cleanup-pr-artifacts.yml + permissions: + contents: write + with: + pr-number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/test-public-workflows.yml b/.github/workflows/test-public-workflows.yml index 27b5e1b..b4f2070 100644 --- a/.github/workflows/test-public-workflows.yml +++ b/.github/workflows/test-public-workflows.yml @@ -10,7 +10,7 @@ on: branches: - main - release/** - types: [opened, synchronize, reopened, ready_for_review] + types: [opened, synchronize, reopened, ready_for_review, closed] workflow_dispatch: concurrency: @@ -24,7 +24,7 @@ jobs: detect: name: Detect Changes runs-on: ubuntu-24.04 - if: github.event_name != 'pull_request' || github.event.pull_request.draft == false + if: (github.event_name != 'pull_request' || github.event.pull_request.draft == false) && github.event.action != 'closed' permissions: contents: read pull-requests: read @@ -157,6 +157,7 @@ jobs: build-plugin-zip: name: Build Plugin Zip + if: github.event_name != 'pull_request' || github.event.action != 'closed' permissions: contents: read uses: ./.github/workflows/reusable-build-public.yml @@ -178,3 +179,12 @@ jobs: run-id: ${{ github.run_id }} artifact-prefix: 'plugin-skeleton-d-pr-public' artifact-filename: 'plugin-skeleton-d.zip' + + cleanup-pr-artifacts: + name: Cleanup PR Artifacts + if: github.event_name == 'pull_request' && github.event.action == 'closed' + uses: ./.github/workflows/reusable-cleanup-pr-artifacts-public.yml + permissions: + contents: write + with: + pr-number: ${{ github.event.pull_request.number }} From 57b349f7ed5a0c8d476e400a5b9ce476504ec1ca Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 28 May 2026 16:14:28 +0000 Subject: [PATCH 2/2] fix: update playground pr preview and cleanup artifacts - Set artifacts-to-keep to 1 to replace old artifacts on new commits - Create standalone cleanup workflow to delete artifacts from ci-artifacts when PR is closed --- .github/workflows/ci.yml | 14 +---- ...c.yml => cleanup-playground-artifacts.yml} | 15 ++--- .../reusable-cleanup-pr-artifacts.yml | 55 ------------------- .github/workflows/test-private-workflows.yml | 14 +---- .github/workflows/test-public-workflows.yml | 14 +---- 5 files changed, 11 insertions(+), 101 deletions(-) rename .github/workflows/{reusable-cleanup-pr-artifacts-public.yml => cleanup-playground-artifacts.yml} (70%) delete mode 100644 .github/workflows/reusable-cleanup-pr-artifacts.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d5c546..312469f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: branches: - main - release/** - types: [opened, synchronize, reopened, ready_for_review, closed] + types: [opened, synchronize, reopened, ready_for_review] workflow_dispatch: concurrency: @@ -22,7 +22,7 @@ jobs: detect: name: Detect Changes runs-on: ubuntu-latest - if: (github.event_name != 'pull_request' || github.event.pull_request.draft == false) && github.event.action != 'closed' + if: github.event_name != 'pull_request' || github.event.pull_request.draft == false permissions: contents: read pull-requests: read @@ -186,7 +186,6 @@ jobs: build-plugin-zip: name: Build Plugin Zip - if: github.event_name != 'pull_request' || github.event.action != 'closed' permissions: contents: read uses: ./.github/workflows/reusable-build-public.yml @@ -210,12 +209,3 @@ jobs: run-id: ${{ github.run_id }} artifact-prefix: 'plugin-skeleton-d-pr' artifact-filename: 'plugin-skeleton-d.zip' - - cleanup-pr-artifacts: - name: Cleanup PR Artifacts - if: github.event_name == 'pull_request' && github.event.action == 'closed' - uses: ./.github/workflows/reusable-cleanup-pr-artifacts-public.yml - permissions: - contents: write - with: - pr-number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/reusable-cleanup-pr-artifacts-public.yml b/.github/workflows/cleanup-playground-artifacts.yml similarity index 70% rename from .github/workflows/reusable-cleanup-pr-artifacts-public.yml rename to .github/workflows/cleanup-playground-artifacts.yml index 043865c..2b8c9d1 100644 --- a/.github/workflows/reusable-cleanup-pr-artifacts-public.yml +++ b/.github/workflows/cleanup-playground-artifacts.yml @@ -1,21 +1,16 @@ name: Cleanup WordPress Playground PR Artifacts on: - workflow_call: - inputs: - pr-number: - description: 'The pull request number' - required: true - type: string + pull_request: + types: [closed] -permissions: {} +permissions: + contents: write jobs: cleanup-artifacts: name: Cleanup PR Artifacts runs-on: ubuntu-24.04 - permissions: - contents: write steps: - name: Cleanup PR artifacts from release env: @@ -23,7 +18,7 @@ jobs: 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-${{ inputs.pr-number }}-"* ]]; then + 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 diff --git a/.github/workflows/reusable-cleanup-pr-artifacts.yml b/.github/workflows/reusable-cleanup-pr-artifacts.yml deleted file mode 100644 index e180419..0000000 --- a/.github/workflows/reusable-cleanup-pr-artifacts.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Cleanup WordPress Playground PR Artifacts - -on: - workflow_call: - inputs: - pr-number: - description: 'The pull request number' - required: true - type: string - -permissions: {} - -jobs: - cleanup-artifacts: - name: Cleanup PR Artifacts - runs-on: [public-repo] - container: - image: ghcr.io/actions/actions-runner@sha256:1ad983536759ceec39ed75a2c8f007ca8c37b66eee35ed86f13623b29a4db97d # v2.333.0 - permissions: - contents: write - steps: - - name: Install GH cli - run: | - curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null - sudo apt-get update - sudo apt install -y gh - - - 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-${{ inputs.pr-number }}-"* ]]; then - echo "Deleting $asset..." - gh release delete-asset ci-artifacts "$asset" --repo ${{ github.repository }} -y || true - fi - done - - - name: Cleanup Workspace & Home to avoid pollution - if: always() - run: | - # Wipes the actual code, build artifacts, and hidden files - sudo rm -rf ./* .[!.]* 2>/dev/null || true - - # Deletes everything inside _temp EXCEPT the locked mount points - sudo find /__w/_temp/ -mindepth 1 -maxdepth 1 ! -name '_github_home' ! -name '_github_workflow' -exec rm -rf {} + - - # Empties the contents of the locked directories without deleting the folders themselves - sudo rm -rf /github/home/* || true - sudo rm -rf /github/home/.* 2>/dev/null || true - - sudo rm -rf /github/workflow/* || true - sudo rm -rf /github/workflow/.* 2>/dev/null || true diff --git a/.github/workflows/test-private-workflows.yml b/.github/workflows/test-private-workflows.yml index ee62334..2bbc164 100644 --- a/.github/workflows/test-private-workflows.yml +++ b/.github/workflows/test-private-workflows.yml @@ -10,7 +10,7 @@ on: branches: - main - release/** - types: [opened, synchronize, reopened, ready_for_review, closed] + types: [opened, synchronize, reopened, ready_for_review] workflow_dispatch: concurrency: @@ -24,7 +24,7 @@ jobs: detect: name: Detect Changes runs-on: ubuntu-24.04 - if: (github.event_name != 'pull_request' || github.event.pull_request.draft == false) && github.event.action != 'closed' + if: github.event_name != 'pull_request' || github.event.pull_request.draft == false permissions: contents: read pull-requests: read @@ -157,7 +157,6 @@ jobs: build-plugin-zip: name: Build Plugin Zip - if: github.event_name != 'pull_request' || github.event.action != 'closed' permissions: contents: read uses: ./.github/workflows/reusable-build.yml @@ -180,12 +179,3 @@ jobs: run-id: ${{ github.run_id }} artifact-prefix: 'plugin-skeleton-d-pr-private' artifact-filename: 'plugin-skeleton-d.zip' - - cleanup-pr-artifacts: - name: Cleanup PR Artifacts - if: github.event_name == 'pull_request' && github.event.action == 'closed' - uses: ./.github/workflows/reusable-cleanup-pr-artifacts.yml - permissions: - contents: write - with: - pr-number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/test-public-workflows.yml b/.github/workflows/test-public-workflows.yml index b4f2070..27b5e1b 100644 --- a/.github/workflows/test-public-workflows.yml +++ b/.github/workflows/test-public-workflows.yml @@ -10,7 +10,7 @@ on: branches: - main - release/** - types: [opened, synchronize, reopened, ready_for_review, closed] + types: [opened, synchronize, reopened, ready_for_review] workflow_dispatch: concurrency: @@ -24,7 +24,7 @@ jobs: detect: name: Detect Changes runs-on: ubuntu-24.04 - if: (github.event_name != 'pull_request' || github.event.pull_request.draft == false) && github.event.action != 'closed' + if: github.event_name != 'pull_request' || github.event.pull_request.draft == false permissions: contents: read pull-requests: read @@ -157,7 +157,6 @@ jobs: build-plugin-zip: name: Build Plugin Zip - if: github.event_name != 'pull_request' || github.event.action != 'closed' permissions: contents: read uses: ./.github/workflows/reusable-build-public.yml @@ -179,12 +178,3 @@ jobs: run-id: ${{ github.run_id }} artifact-prefix: 'plugin-skeleton-d-pr-public' artifact-filename: 'plugin-skeleton-d.zip' - - cleanup-pr-artifacts: - name: Cleanup PR Artifacts - if: github.event_name == 'pull_request' && github.event.action == 'closed' - uses: ./.github/workflows/reusable-cleanup-pr-artifacts-public.yml - permissions: - contents: write - with: - pr-number: ${{ github.event.pull_request.number }}