forked from Amit86/minimanager
-
Notifications
You must be signed in to change notification settings - Fork 38
54 lines (44 loc) · 1.79 KB
/
IP2Location.yaml
File metadata and controls
54 lines (44 loc) · 1.79 KB
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
54
name: Automatically update IP2Location database
on:
# Runs on the first day of each month
schedule:
- cron: '0 9 1 * *'
workflow_dispatch: { }
jobs:
download_extract_and_commit:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Unzip Utility
run: sudo apt-get install unzip -y
- name: Define Paths and Files
run: |
echo "DOWNLOAD_URL=https://download.ip2location.com/lite/IP2LOCATION-LITE-DB1.BIN.ZIP" >> $GITHUB_ENV
echo "DOWNLOAD_FILENAME=IP2LOCATION-LITE-DB1.BIN.ZIP" >> $GITHUB_ENV
echo "TARGET_DIR=libs/IP2Location/databases/" >> $GITHUB_ENV
- name: Create Target Directory
run: mkdir -p ${{ env.TARGET_DIR }}
- name: Download and Extract File
run: |
echo "Downloading and extracting to ${{ env.TARGET_DIR }}..."
curl -sS -L -o ${{ env.TARGET_DIR }}${{ env.DOWNLOAD_FILENAME }} ${{ env.DOWNLOAD_URL }}
unzip -o ${{ env.TARGET_DIR }}${{ env.DOWNLOAD_FILENAME }} -d ${{ env.TARGET_DIR }}
echo "Cleaning up ZIP file..."
rm ${{ env.TARGET_DIR }}${{ env.DOWNLOAD_FILENAME }}
- name: Set up Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit if changes exist
run: |
git add ${{ env.TARGET_DIR }}
git diff --quiet --exit-code --cached || git commit -m "chore(auto): Update IP2Location database"
- name: Push changes
run: git push origin ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}