Skip to content

Commit ca04ef8

Browse files
committed
[add][m] Adding github actions
1 parent d436648 commit ca04ef8

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/actions.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Automated geoip2-ipv4 update
2+
3+
on:
4+
schedule:
5+
# Run weekly
6+
- cron: '0 0 * * 0'
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
13+
workflow_dispatch:
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
if: github.ref == 'refs/heads/main'
20+
21+
steps:
22+
- name: Check out repository
23+
uses: actions/checkout@v3
24+
25+
- name: Set up Python 3.12
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: '3.12'
29+
30+
- name: Install dependencies
31+
run: |
32+
pip install -r scripts/requirements.txt
33+
34+
- name: Run CPI Update Script
35+
env:
36+
MAXMIND_USERNAME: ${{ secrets.MAXMIND_USERNAME }}
37+
MAXMIND_PASSWORD: ${{ secrets.MAXMIND_PASSWORD }} # Retrieve API key from GitHub Secrets
38+
run: |
39+
python scripts/process.py
40+
41+
- name: Configure Git
42+
run: |
43+
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
44+
git config --global user.name "${{ env.CI_COMMIT_NAME }}"
45+
env:
46+
CI_COMMIT_NAME: "Automated commit"
47+
CI_COMMIT_EMAIL: "actions@users.noreply.github.com"
48+
49+
- name: Commit and Push changes
50+
run: |
51+
git diff --quiet && echo "No changes to commit" || (
52+
git add data/ &&
53+
git commit -m "${{ env.CI_COMMIT_MESSAGE }}" &&
54+
git push origin main
55+
)
56+
env:
57+
CI_COMMIT_MESSAGE: "Automated commit"

0 commit comments

Comments
 (0)