Skip to content

Now cache and download the DBs #7

Now cache and download the DBs

Now cache and download the DBs #7

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Automated build
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-tools:
runs-on: ubuntu-latest
env:
GO_VERSION: '1.21.4'
MMDBMELD_TAG: 'v0.1.1'
steps:
- name: Check for Cached Tools Build
uses: actions/cache@v3
id: tools-cache
with:
path: ./tools
key: ${{ env.GO_VERSION }}-${{ env.MMDBMELD_TAG }}
- name: Set up Go
uses: actions/setup-go@v4
if: steps.tools-cache.outputs.cache-hit != 'true'
with:
go-version: '1.21.4'
- name: Clone mmdbmeld
if: steps.tools-cache.outputs.cache-hit != 'true'
run: git clone -b v0.1.1 https://github.com/safing/mmdbmeld.git
- name: Build mmdbmeld
if: steps.tools-cache.outputs.cache-hit != 'true'
working-directory: ./mmdbmeld
run: |
go build -C cmd/mmdbmeld
go build -C cmd/mmdbcheck
- name: Move the Tools
if: steps.tools-cache.outputs.cache-hit != 'true'
run: |
mkdir ./tools
cp ./mmdbmeld/cmd/mmdbmeld/mmdbmeld ./mmdbmeld/cmd/mmdbcheck/mmdbcheck ./tools
- name: Upload Tools To Artifacts
uses: actions/upload-artifact@v3
with:
name: tools
path: ./tools
build-database:
runs-on: ubuntu-latest
needs: ['build-tools']
steps:
- uses: actions/checkout@v4
- name: Download Tools
uses: actions/download-artifact@v3
with:
name: tools
- name: Fetch DB Cache
uses: actions/cache@v3
with:
key: DB
path: |
./DBs
- name: Download DBs
run: |
mkdir DBs && cd DBs
curl --silent --show-error \
--etag-save geo-whois-asn-country-ipv4.csv.etag \
--etag-compare geo-whois-asn-country-ipv4.csv.etag \
--output geo-whois-asn-country-ipv4.csv \
"https://cdn.jsdelivr.net/npm/@ip-location-db/geo-whois-asn-country/geo-whois-asn-country-ipv4.csv"
curl --silent --show-error \
--etag-save geo-whois-asn-country-ipv6.csv.etag \
--etag-compare geo-whois-asn-country-ipv6.csv.etag \
--output geo-whois-asn-country-ipv6.csv \
"https://cdn.jsdelivr.net/npm/@ip-location-db/geo-whois-asn-country/geo-whois-asn-country-ipv6.csv"
- name: Save DB Cache
uses: actions/cache/save@v3
with:
key: DB
path: |
./DBs
- name: Check directory
run: tree