Delete old BackstopJS preview pages #252
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Delete old BackstopJS preview pages | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '5 4 * * *' | |
concurrency: | |
group: visual-regression | |
jobs: | |
visual-regression-cleanup: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
- name: Setup Git user | |
run: | | |
git config --global user.name github-actions | |
git config --global user.email github-actions@github.com | |
- name: Remove the folder | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
for d in pull/*; do | |
id=$(echo $d | cut -d / -f2) | |
state=$(gh pr view $id --json state --jq .state) | |
if [ "$state" != "OPEN" ]; then | |
rm -r pull/$id | |
fi | |
done | |
if [[ $(git status --porcelain) ]]; then | |
git add . | |
git commit -m 'Automated commit' | |
git push | |
fi | |