Configure Git to push as BrewTestBot
#9
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: Check patch references | |
on: | |
push: | |
branches-ignore: | |
- dependabot/** | |
schedule: | |
# Once every day at midnight UTC | |
- cron: "0 0 * * *" | |
jobs: | |
stale: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout patches | |
uses: actions/checkout@v4 | |
- name: Checkout core | |
uses: actions/checkout@v4 | |
with: | |
repository: 'homebrew/homebrew-core' | |
path: homebrew-core | |
- name: Configure Git user | |
uses: Homebrew/actions/git-user-config@master | |
with: | |
username: BrewTestBot | |
- name: Detect references | |
run: | | |
#!/bin/bash | |
core_patches=$(git -C homebrew-core grep -h "Homebrew/formula-patches" | awk -F/ '{print $(NF-1)"/"$NF}' | tr -d '"') | |
all_patches=$(git ls-files -- '*/*' ':^.*/*') | |
git checkout -b remove-unused-patches | |
for patch in $all_patches; do | |
if ! grep -qx "$core_patches" <<< "$patch"; then | |
echo "Unused patch: $patch; deleting." | |
git rm "$patch" | |
git commit -m "Remove unused patch: $patch" | |
fi | |
done | |
git push origin remove-unused-patches |