-
Notifications
You must be signed in to change notification settings - Fork 33
53 lines (49 loc) · 2.04 KB
/
delete_test_reports.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Delete playwright test reports
on:
pull_request_target:
types:
- closed
jobs:
delete_reports:
name: Delete Playwright Test Reports for PR ${{ github.event.number }}
runs-on: ubuntu-latest
env:
# Folder on gh-pages branch that contains all test reports for a PR
PR_REPORTS_DIR: reports/pr-${{ github.event.number }}
steps:
- uses: actions/checkout@main
with:
ref: gh-pages
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set Git User
run: |
git config --global user.email "github-action@example.com"
git config --global user.name "GitHub Action"
- name: Check for workflow reports
id: has-reports
run: |
if [ -z "$(ls -A $PR_REPORTS_DIR)" ]; then
echo "PR_REPORTS_EXISTS=false" >> $GITHUB_OUTPUT
else
echo "PR_REPORTS_EXISTS=true" >> $GITHUB_OUTPUT
fi
- name: Delete reports from repo for PR ${{ github.event.number }}
if: ${{ steps.has-reports.outputs.PR_REPORTS_EXISTS == 'true' }}
timeout-minutes: 3
run: |
rm -rf reports/pr-${{ github.event.number }}
git add .
git commit -m "workflow: remove all reports for PR #${{ github.event.number }}"
# In case if another action job pushed to gh-pages while we are rebasing for the current job
while true; do
git pull --rebase
if [ $? -ne 0 ]; then
echo "Failed to rebase. Please review manually."
exit 1
fi
git push
if [ $? -eq 0 ]; then
echo "Successfully pushed HTML reports to repo."
exit 0
fi
done