Skip to content

fix: prevent custom config keys being removed when updating resources [WD-9348] #106

fix: prevent custom config keys being removed when updating resources [WD-9348]

fix: prevent custom config keys being removed when updating resources [WD-9348] #106

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