ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto
1name: Cleanup Decision Graph PNGs
2
3on:
4 pull_request:
5 types: [closed]
6
7jobs:
8 cleanup:
9 # Only run if PR was merged (not just closed)
10 if: github.event.pull_request.merged == true
11 runs-on: ubuntu-latest
12
13 steps:
14 - name: Checkout
15 uses: actions/checkout@v4
16 with:
17 fetch-depth: 0
18 token: ${{ secrets.GITHUB_TOKEN }}
19
20 - name: Find and remove decision graph PNGs
21 id: find-pngs
22 run: |
23 # Find decision graph PNGs (in docs/ or root)
24 PNGS=$(find . -name "decision-graph*.png" -o -name "deciduous-graph*.png" 2>/dev/null | grep -v node_modules || true)
25
26 if [ -z "$PNGS" ]; then
27 echo "No decision graph PNGs found"
28 echo "found=false" >> $GITHUB_OUTPUT
29 else
30 echo "Found PNGs to clean up:"
31 echo "$PNGS"
32 echo "found=true" >> $GITHUB_OUTPUT
33
34 # Remove the files
35 echo "$PNGS" | xargs rm -f
36
37 # Also remove corresponding .dot files
38 for png in $PNGS; do
39 dot_file="${png%.png}.dot"
40 if [ -f "$dot_file" ]; then
41 rm -f "$dot_file"
42 echo "Also removed: $dot_file"
43 fi
44 done
45 fi
46
47 - name: Create cleanup PR
48 if: steps.find-pngs.outputs.found == 'true'
49 run: |
50 # Check if there are changes to commit
51 if git diff --quiet && git diff --staged --quiet; then
52 echo "No changes to commit"
53 exit 0
54 fi
55
56 # Configure git
57 git config user.name "github-actions[bot]"
58 git config user.email "github-actions[bot]@users.noreply.github.com"
59
60 # Create branch and commit
61 BRANCH="cleanup/decision-graphs-pr-${{ github.event.pull_request.number }}"
62 git checkout -b "$BRANCH"
63 git add -A
64 git commit -m "chore: cleanup decision graph assets from PR #${{ github.event.pull_request.number }}"
65 git push origin "$BRANCH"
66
67 # Create and auto-merge PR
68 gh pr create \
69 --title "chore: cleanup decision graph assets from PR #${{ github.event.pull_request.number }}" \
70 --body "Automated cleanup of decision graph PNG/DOT files that were used in PR #${{ github.event.pull_request.number }}.
71
72 These files served their purpose for PR review and are no longer needed." \
73 --head "$BRANCH" \
74 --base main
75
76 # Auto-merge (requires auto-merge enabled on repo)
77 gh pr merge "$BRANCH" --auto --squash --delete-branch || echo "Auto-merge not enabled, PR created for manual merge"
78 env:
79 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}