-
-
Notifications
You must be signed in to change notification settings - Fork 9
53 lines (44 loc) · 1.62 KB
/
update.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Update DB
on:
schedule:
- cron: "0 0 * * 0" # at 00:00 on Sunday
workflow_dispatch:
env:
DB_PATH: db/tlds.txt
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: "Install dependencies"
run: sudo apt install curl -y
- name: "Check out code"
uses: actions/checkout@v4
- name: "Check for updates"
id: check
run: |
local_ver="$(grep -oP '^# Version \K\d+' ${{ env.DB_PATH }})"
remote_ver="$(curl -sr 0-20 ${{ secrets.REMOTE_DB }} | grep -oP '^# Version \K\d+')"
echo -e "Date: $(date)"
echo -e "Local version: ${local_ver}"
echo -e "Remote version: ${remote_ver}"
if [[ "${local_ver}" -lt "${remote_ver}" ]]; then
echo "isUpdated=false" >> $GITHUB_OUTPUT
else
echo "isUpdated=true" >> $GITHUB_OUTPUT
fi
echo "remoteVersion=${remote_ver}" >> $GITHUB_OUTPUT
- name: "Update DB..."
if: steps.check.outputs.isUpdated == 'false'
run: curl -kLo ${{ env.DB_PATH }} ${{ secrets.REMOTE_DB }}
- name: Create Pull Request
if: steps.check.outputs.isUpdated == 'false'
uses: peter-evans/create-pull-request@v3
with:
body: "Automated update TLDs data."
branch-suffix: "short-commit-hash"
branch: "update/db"
commit-message: "db: Update DB (${{ steps.check.outputs.remoteVersion }})"
committer: "ghost <ghost@users.noreply.github.com>"
delete-branch: true
reviewers: "dwisiswant0"
title: "db: Update DB (${{ steps.check.outputs.remoteVersion }})"