Generate pihole no-copycat blocklist #597
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: Generate pihole no-copycat blocklist | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Checkout last release | |
uses: robinraju/release-downloader@v1.3 | |
with: | |
latest: true | |
tarBall: false | |
zipBall: false | |
fileName: "no_copycats.txt" | |
repository: ${{ github.repository }} | |
- name: Install dependencies | |
run: | | |
set -eu | |
cat << EOF | sudo tee /etc/apt/apt.conf.d/99custom | |
quiet "1"; | |
Dpkg::Options {"--force-confold";}; | |
APT | |
{ | |
Get | |
{ | |
Purge "true"; | |
Remove "true"; | |
Upgrade "true"; | |
Download "true"; | |
Assume-Yes "true"; | |
Fix-Broken "true"; | |
Fix-Missing "true"; | |
List-Cleanup "false"; | |
Show-Versions "false"; | |
Show-Upgraded "false"; | |
AutomaticRemove "true"; | |
Install-Suggests "false"; | |
Upgrade-Allow-New "true"; | |
Install-Recommends "false"; | |
}; | |
}; | |
EOF | |
sudo sh -euc "$(cat << EOF | |
export DEBIAN_FRONTEND=noninteractive | |
export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn | |
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64 | |
add-apt-repository ppa:rmescandon/yq | |
apt-get update | |
apt-get install yq curl | |
EOF | |
)" | |
- name: Generate blocklist | |
id: generate | |
run: | | |
set -eu | |
get_domains() { | |
curl -sSL "$1" |\ | |
yq e '.[].domain' - |\ | |
awk -F'.' -vOFS='.' '{ if ($1 ~ /^(*|(www))$/) { $1 = ""; print substr($0,2) } else { print } }' | |
} | |
cat << EOF >| no_copycats.new | |
# Pi-hole no copycats blocklist | |
# | |
# url: https://github.com/HeavenVolkoff/no-copycats | |
# version: 1.0 | |
# created-by: https://github.com/HeavenVolkoff | |
EOF | |
{ | |
get_domains "https://raw.githubusercontent.com/arosh/ublacklist-github-translation/master/domain-list.yml" | |
get_domains "https://raw.githubusercontent.com/arosh/ublacklist-stackoverflow-translation/master/domain-list.yml" | |
} | sort | uniq >> no_copycats.new | |
if cmp --silent no_copycats.txt no_copycats.new; then | |
echo "::set-output name=different::no" | |
else | |
mv no_copycats.new no_copycats.txt | |
echo "::set-output name=different::yes" | |
fi | |
- name: Generate release tag name | |
id: tag | |
if: ${{ steps.generate.outputs.different == 'yes' }} | |
run: | | |
echo "::set-output name=release_tag::$(date +"%Y.%m.%d_%H-%M")" | |
- name: Release | |
if: ${{ steps.generate.outputs.different == 'yes' }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: no_copycats.txt | |
tag_name: ${{ steps.tag.outputs.release_tag }} |