Skip to content

Auto Appfilter Updater #21

Auto Appfilter Updater

Auto Appfilter Updater #21

name: Auto Appfilter Updater
on:
workflow_dispatch:
env:
UPDATEABLE_URL: https://arcticons.com/assets/updatable.txt # The URL to the updatable.txt file, change if necessary
PACKAGE_BLACKLIST_PATH: .github/workflows/appfilter_auto_updater/blacklists/packageblacklist.txt # The path to the package blacklist file, change if necessary
DRAWABLE_BLACKLIST_PATH: .github/workflows/appfilter_auto_updater/blacklists/drawableblacklist.txt # The path to the drawable blacklist file, change if necessary
COMPONENT_BLACKLIST_PATH: .github/workflows/appfilter_auto_updater/blacklists/componentblacklist.txt # The path to the component blacklist file, change if necessary
APPFILTER_PATH: newicons/appfilter.xml # The path to the appfilter.xml file, change if necessary
BASE_BRANCH: main # The base branch for the pull request, change if necessary
PR_TITLE: Update Appfilter.xml # The title of the pull request, change if necessary
PR_BODY: Automated update of `appfilter.xml` via GitHub Action, applying blacklist filters. # The body of the pull request, change if necessary
OWNER: Arcticons-Team # The owner of the repository, change if necessary
BRANCH: auto-xml-update # This branch will be created if it does not exist
jobs:
check-pr:
if : ${{ github.repository == vars.REPOSITORY }}
runs-on: ubuntu-latest
outputs:
existsnot: ${{ steps.check.outputs.existsnot }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
ref: ${{ env.BASE_BRANCH }}
sparse-checkout: |
.git
- name: Check if PR exists
id: check
run: |
if gh pr list -H "$BRANCH" -B "$BASE_BRANCH" --json number --jq '.[].number' | grep -q '[0-9]'; then
echo "existsnot=false" >> "$GITHUB_OUTPUT"
else
echo "existsnot=true" >> "$GITHUB_OUTPUT"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: ${{ env.BRANCH }}
BASE_BRANCH: ${{ env.BASE_BRANCH }}
update-pr:
needs: check-pr
if: needs.check-pr.outputs.existsnot == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
ref: ${{ env.BASE_BRANCH }}
sparse-checkout: |
newicons/appfilter.xml
.github/workflows/
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.x'
cache: 'pip'
- run: pip install -r .github/workflows/requirements.txt
- name: Execute Python Script
run: |
python .github/workflows/appfilter_auto_updater/appfilter_auto_updater.py
git add $APPFILTER_PATH
git commit -m "Update appfilter.xml" || echo "No changes to commit"
- name: Create or update branch
run: |
git fetch origin $BRANCH || true
git branch -f $BRANCH
git push origin $BRANCH --force
- name: Create pull request
run: |
gh pr create -B "$BASE_BRANCH" -H "$OWNER:$BRANCH" --title "$PR_TITLE" --body "$PR_BODY"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}