-
Notifications
You must be signed in to change notification settings - Fork 308
59 lines (53 loc) · 1.69 KB
/
cleanup-report.yml
File metadata and controls
59 lines (53 loc) · 1.69 KB
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
54
55
56
57
58
59
name: Delete Visual Tests Reports
on:
delete:
branches-ignore: [master, main, gh-pages]
concurrency:
group: ${{ github.event.ref }}
cancel-in-progress: true
jobs:
delete_reports:
name: Delete Reports
runs-on: ubuntu-latest
permissions:
contents: write
env:
BRANCH_REPORTS_DIR: reports/${{ github.event.ref }}
steps:
- name: Checkout GitHub Pages Branch
uses: actions/checkout@v5
with:
ref: gh-pages
- 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: Check for workflow reports
run: |
if [ -d "$BRANCH_REPORTS_DIR" ] && [ "$(ls -A $BRANCH_REPORTS_DIR)" ]; then
echo "BRANCH_REPORTS_EXIST=true" >> "$GITHUB_ENV"
else
echo "BRANCH_REPORTS_EXIST=false" >> "$GITHUB_ENV"
fi
- name: Delete reports from repo for branch
if: ${{ env.BRANCH_REPORTS_EXIST == 'true' }}
timeout-minutes: 3
env:
DELETED_BRANCH: ${{ github.event.ref }}
run: |
cd "$(dirname "$BRANCH_REPORTS_DIR")"
rm -rf "${DELETED_BRANCH}"
git add .
git commit -m "workflow: remove all reports for branch ${DELETED_BRANCH}"
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