Skip to content

Commit

Permalink
First test of action sort
Browse files Browse the repository at this point in the history
Fixes #43
  • Loading branch information
spirillen committed Mar 20, 2024
1 parent 72133ea commit 25bf9d8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mypdns
8 changes: 5 additions & 3 deletions tools/hierarchical_sort.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

## This script should be placed in pre-commit-hooks
set -xe
Expand All @@ -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

0 comments on commit 25bf9d8

Please sign in to comment.