Skip to content

Commit

Permalink
Add cron update
Browse files Browse the repository at this point in the history
  • Loading branch information
sapics committed Sep 4, 2024
1 parent 8e803e9 commit 6ab01bd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/auto-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Auto database update
on:
schedule:
- cron: '24 21,23 * * Tue,Wed,Fri,Sat'
workflow_dispatch:
jobs:
release:
name: latest version
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: 'https://registry.npmjs.org'
- name: install dependencies
run: npm i
- name: update
run: npm run updatedb
- name: test
run: npm run test
- name: commit
run: scripts/release.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{secrets.GTOKEN}}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ You can change the memory usage or lookup time, by customizing location informat
## Synopsis

```javascript
// ESM
import { lookup } from 'ip-location-api'
// or CJS format
// const { lookup } = require('ip-location-api')
Expand Down
11 changes: 11 additions & 0 deletions script/auto-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# get current version from package.json
RES1=`find data -name '*.dat' -size -1000k 2>/dev/null`
if [ -z "$RES1" ]; then
if ! git diff --quiet HEAD -- *.dat; then
VERT=`node -p "var j=require('./package.json');j.version=j.version.split('.').slice(0,-1).join('.')+'.'+require('dayjs')().format('YYYYMMDD');require('fs').writeFileSync('./package.json',JSON.stringify(j,null,2));j.version;"`
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -a -m "v${VERT} auto update ip database"
npm publish
fi
fi

0 comments on commit 6ab01bd

Please sign in to comment.