diff --git a/.forgejo/workflows/updatechecker.yml b/.forgejo/workflows/updatechecker.yml index 73d216e..be56fd7 100644 --- a/.forgejo/workflows/updatechecker.yml +++ b/.forgejo/workflows/updatechecker.yml @@ -1,17 +1,19 @@ on: schedule: - cron: "2 0 1 * *" + workflow_dispatch: + jobs: checkupdates: runs-on: docker steps: - uses: actions/checkout@v3 - - run: make update + - run: make clean_data update - run: | git config user.name "Snegurochka" git config user.email "snegurochka@frostfs.info" git switch -c update-dbs git add . git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@git.frostfs.info/TrueCloudLab/frostfs-locode-db - git commit -m "Automatic database update (UN/LOCODE version $(cat tmp/locode-version.txt))" && \ + git commit -sm "Automatic database update (UN/LOCODE version $(cat tmp/locode-version.txt))" && \ git push origin HEAD:refs/for/master -o topic=automatic-database-update diff --git a/Makefile b/Makefile index 27428ad..925201d 100755 --- a/Makefile +++ b/Makefile @@ -71,8 +71,11 @@ data/countries.dat.gz: $(DIRS) # See https://unece.org/trade/cefact/UNLOCODE-Download tmp/locode.csv.zip :$(DIRS) DOWNLOADURL=$$(wget -O - https://unece.org/trade/cefact/UNLOCODE-Download \ - | grep -oP '(?<=href=")\S+loc\d+csv\.zip'); \ - echo "$$DOWNLOADURL" | grep -oP '(?<=loc)\d+' > tmp/locode-version.txt; \ + --header='User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0' \ + | grep -oP '(?<=href=")\S+loc\d+csv\.zip' \ + | head -n1) && \ + test -n "$$DOWNLOADURL" && \ + echo "$$DOWNLOADURL" | grep -oP '(?<=loc)\d+' > tmp/locode-version.txt && \ wget -c "$$DOWNLOADURL" -O tmp/locode.csv.zip data/unlocode-SubdivisionCodes.csv.gz: tmp/locode.csv.zip