| 1 |
name: Sync Public Suffix List |
| 2 |
|
| 3 |
on: |
| 4 |
schedule: |
| 5 |
# Run on the first day of the month at 00:00 UTC |
| 6 |
- cron: '0 0 1 * *' |
| 7 |
workflow_dispatch: |
| 8 |
|
| 9 |
permissions: |
| 10 |
contents: write |
| 11 |
pull-requests: write |
| 12 |
|
| 13 |
jobs: |
| 14 |
sync: |
| 15 |
if: github.repository == 'rspamd/rspamd' |
| 16 |
runs-on: ubuntu-24.04 |
| 17 |
steps: |
| 18 |
- name: Checkout repository |
| 19 |
uses: actions/checkout@v4 |
| 20 |
|
| 21 |
- name: Install Perl dependencies |
| 22 |
run: | |
| 23 |
sudo apt-get update |
| 24 |
sudo apt-get install -y libnet-idn-encode-perl |
| 25 |
|
| 26 |
- name: Download public suffix list |
| 27 |
run: | |
| 28 |
curl -sSL https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat -o /tmp/public_suffix_list.dat |
| 29 |
|
| 30 |
- name: Process public suffix list |
| 31 |
run: | |
| 32 |
perl contrib/publicsuffix/idn.pl < /tmp/public_suffix_list.dat > contrib/publicsuffix/effective_tld_names.dat |
| 33 |
|
| 34 |
- name: Check for changes |
| 35 |
id: check_changes |
| 36 |
run: | |
| 37 |
if git diff --quiet contrib/publicsuffix/effective_tld_names.dat; then |
| 38 |
echo "has_changes=false" >> $GITHUB_OUTPUT |
| 39 |
else |
| 40 |
echo "has_changes=true" >> $GITHUB_OUTPUT |
| 41 |
fi |
| 42 |
|
| 43 |
- name: Create Pull Request |
| 44 |
if: steps.check_changes.outputs.has_changes == 'true' |
| 45 |
run: | |
| 46 |
git config user.name "github-actions[bot]" |
| 47 |
git config user.email "github-actions[bot]@users.noreply.github.com" |
| 48 |
|
| 49 |
# Delete the branch if it exists (locally and remotely) |
| 50 |
git branch -D sync-public-suffix-list 2>/dev/null || true |
| 51 |
git push origin --delete sync-public-suffix-list 2>/dev/null || true |
| 52 |
|
| 53 |
# Create new branch and commit changes |
| 54 |
git checkout -b sync-public-suffix-list |
| 55 |
git add contrib/publicsuffix/effective_tld_names.dat |
| 56 |
git commit -m "[Minor] Update public suffix list" |
| 57 |
git push origin sync-public-suffix-list |
| 58 |
|
| 59 |
# Create PR |
| 60 |
gh pr create \ |
| 61 |
--title "Update public suffix list" \ |
| 62 |
--body "This PR updates the public suffix list from https://github.com/publicsuffix/list. This is an automated update generated by the sync workflow." \ |
| 63 |
--base master \ |
| 64 |
--head sync-public-suffix-list |
| 65 |
env: |
| 66 |
GH_TOKEN: ${{ github.token }} |