Skip to content

Commit

Permalink
Add auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
sapics committed Sep 11, 2024
1 parent a44fbb9 commit 67524e1
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/auto-update-country.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Auto database update browser-country
on:
schedule:
- cron: '42 19 * * *'
workflow_dispatch:
jobs:
release:
name: Auto database update browser-country
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-browser-country
- name: test
run: npm run test
- name: commit
run: script/auto-update-country.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{secrets.GTOKEN}}
31 changes: 31 additions & 0 deletions .github/workflows/auto-update-geocode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Auto database update browser-geocode
on:
schedule:
- cron: '2 0 1,2,3 * *'
workflow_dispatch:
jobs:
release:
name: Auto database update browser-geocode
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-browser-geocode
- name: test
run: npm run test
- name: commit
run: script/auto-update-geocode.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{secrets.GTOKEN}}
27 changes: 27 additions & 0 deletions script/auto-update-country.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# get current version from package.json

cd browser/country
RES1=`find data -name '*.idx' -size -1k 2>/dev/null`
if [ -z "$RES1" ]; then
if ! git diff --quiet HEAD -- *.idx; 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

cd ../..

cd browser/country-extra
RES2=`find data -name '*.idx' -size -1k 2>/dev/null`
if [ -z "$RES2" ]; then
if ! git diff --quiet HEAD -- *.idx; 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
27 changes: 27 additions & 0 deletions script/auto-update-geocode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# get current version from package.json

cd browser/geocode
RES1=`find data -name '*.idx' -size -1k 2>/dev/null`
if [ -z "$RES1" ]; then
if ! git diff --quiet HEAD -- *.idx; 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

cd ../..

cd browser/geocode-extra
RES2=`find data -name '*.idx' -size -1k 2>/dev/null`
if [ -z "$RES2" ]; then
if ! git diff --quiet HEAD -- *.idx; 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 67524e1

Please sign in to comment.