Cleaner #14
This file contains hidden or 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: "Cleaner" | |
on: | |
#schedule: | |
# - cron: "*/15 * * * *" | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
jobs: | |
sync-files: | |
name: "To clean" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout source repository" | |
uses: actions/checkout@v4 | |
- name: "Run cleaner" | |
run: | | |
LIST=$(curl -Ls https://raw.githubusercontent.com/ivan-hc/AM/main/programs/x86_64-apps) | |
[ -z "$LIST" ] && exit 1 | |
MDS=$(ls apps/* | sed 's:.*/::; s/.md$//g') | |
PNGS=$(ls icons/* | sed 's:.*/::; s/.png$//g') | |
for m in $MDS; do | |
if ! echo "$LIST" | grep -q "◆ $m :"; then | |
rm -f "apps/$m.md" | |
fi | |
done | |
for p in $PNGS; do | |
if ! echo "$LIST" | grep -q "◆ $p :"; then | |
rm -f "icons/$p.png" | |
fi | |
done | |
- name: "Push to Source" | |
run: | | |
git config --global user.name "Portable-Linux-Apps" | |
git config --global user.email "[email protected]" | |
git add apps icons | |
if git diff-index --quiet HEAD; then | |
echo "No changes to commit." >> $GITHUB_STEP_SUMMARY | |
else | |
git commit -m "Clean unneeded pages" | |
git push && echo "Sync to Source succeeded" >> $GITHUB_STEP_SUMMARY | |
fi |