From 25bf9d8bffa9b4b26015247524b1265e494c03c4 Mon Sep 17 00:00:00 2001 From: Spirillen Date: Wed, 20 Mar 2024 05:39:04 +0100 Subject: [PATCH] First test of action sort Fixes https://github.com/mitchellkrogza/phishing/issues/43 --- .github/workflows/master.yml | 45 ++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + tools/hierarchical_sort.sh | 8 ++++--- 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/master.yml create mode 100644 requirements.txt diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 00000000..d3bc3468 --- /dev/null +++ b/.github/workflows/master.yml @@ -0,0 +1,45 @@ +name: Sort sources hierarchical + +on: + pull_request: + push: + branches: + - master + - main + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout the repo + uses: actions/checkout@main + with: + ref: ${{ github.head_ref }} + + - name: Setup Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: 3.11 + run: | + if [ -f requirements.txt ]; then python3.11 -m pip install + --no-cache-dir -r requirements.txt; fi + + - name: 'Sort the lists hierarchical' + run: | + sh "${{ github.workspace }}/tools/hierarchical_sort.sh" + + - name: Git Status + run: git status + + - name: Set commit tag + run: | + tag=$(date +'day: %j of year %Y %H:%M:%S') + + - name: Commit all changed files back to the repository + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Hierarchical sorted the lists $tag" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..03270929 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +mypdns diff --git a/tools/hierarchical_sort.sh b/tools/hierarchical_sort.sh index ddd0ffb4..43e62764 100644 --- a/tools/hierarchical_sort.sh +++ b/tools/hierarchical_sort.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash ## This script should be placed in pre-commit-hooks set -xe @@ -7,9 +7,11 @@ GIT_DIR="$(git rev-parse --show-toplevel)" if [ -d "$GIT_DIR" ]; then cd "${GIT_DIR}" || exit 1 - for i in $(git ls-files -m); do + +FILES=('add-domain' 'add-link' 'add-wildcard-domain' 'falsepositive.list' 'falsepositive_regex.list' 'falsepositive_rzd.list') + + for i in "${FILES[@]}"; do python3.11 "$GIT_DIR/tools/domain-sort.py" <"${i}" >"${i}.tmp" && sed "/^$/d" "${i}.tmp" >"${i}" && rm "${i}.tmp" done - fi