From 45219f4736ed586dd930f432cd504f312c420ae6 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Wed, 30 Apr 2025 00:18:05 +0530 Subject: [PATCH] fix: cleanup html reports when pr is merged/closed (#20089) Co-authored-by: anik@cal.com Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .github/workflows/cleanup-report.yml | 37 ++++++++++++++++++++++++++++ .github/workflows/pr.yml | 11 +++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/cleanup-report.yml diff --git a/.github/workflows/cleanup-report.yml b/.github/workflows/cleanup-report.yml new file mode 100644 index 0000000000..61c08dbad3 --- /dev/null +++ b/.github/workflows/cleanup-report.yml @@ -0,0 +1,37 @@ +on: + workflow_call: + pull_request: + types: [closed] + +permissions: + contents: write + issues: write + pull-requests: write +jobs: + cleanup-report: + runs-on: ubuntu-latest + steps: + - name: Checkout GitHub Pages Branch + uses: actions/checkout@v4 + with: + repository: calcom/test-results + ref: gh-pages + token: ${{ secrets.GH_ACCESS_TOKEN }} + + - name: Set Git User + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Cleanup HTML reports on PR close/merge + env: + BRANCH_REPORTS_DIR: reports/${{ github.event.pull_request.head.ref }} + run: | + if [ -d "$BRANCH_REPORTS_DIR" ]; then + rm -rf "$BRANCH_REPORTS_DIR" + git add . + git commit -m "workflow: remove all reports for branch ${{ github.event.pull_request.head.ref }} (PR closed/merged)" + git push + else + echo "No reports found for branch ${{ github.event.pull_request.head.ref }}. Nothing to clean up." + fi diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d1b72c53d1..02fa8229f9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -219,6 +219,17 @@ jobs: uses: ./.github/workflows/publish-report.yml secrets: inherit + cleanup-report: + name: Cleanup HTML report + if: ${{ !cancelled() && needs.check-label.outputs.run-e2e == 'true' && (github.event.pull_request.merged == true || github.event.pull_request.state == 'closed') }} + permissions: + contents: write + issues: write + pull-requests: write + needs: [changes, check-label, publish-report] + uses: ./.github/workflows/cleanup-report.yml + secrets: inherit + required: needs: [