diff --git a/.github/workflows/GeoLite.yml b/.github/workflows/GeoLite.yml index 72c9b69..51293fb 100644 --- a/.github/workflows/GeoLite.yml +++ b/.github/workflows/GeoLite.yml @@ -1,18 +1,20 @@ -#================================================= +# +# Copyright (c) 2020-2021 P3TERX +# +# This is free software, licensed under the MIT License. +# See /LICENSE for more information. +# # https://github.com/P3TERX/GeoLite.mmdb # Description: Publish GeoLite.mmdb -# Lisence: MIT -# Author: P3TERX -# Blog: https://p3terx.com -#================================================= +# name: Publish GeoLite.mmdb on: + repository_dispatch: + workflow_dispatch: schedule: - - cron: 0 22 */3 * * -# watch: -# types: started + - cron: 0 1 */3 * * jobs: run: @@ -22,13 +24,12 @@ jobs: steps: - name: Download GeoLite.mmdb run: | - wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=${LICENSE_KEY}&suffix=tar.gz" | tar zxvC . - wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${LICENSE_KEY}&suffix=tar.gz" | tar zxvC . - wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${LICENSE_KEY}&suffix=tar.gz" | tar zxvC . + wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=${{ secrets.LICENSE_KEY }}&suffix=tar.gz" | tar zxv + wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${{ secrets.LICENSE_KEY }}&suffix=tar.gz" | tar zxv + wget -nv -O- "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${{ secrets.LICENSE_KEY }}&suffix=tar.gz" | tar zxv mkdir -p upload cp -v GeoLite*/*.mmdb upload - env: - LICENSE_KEY: ${{ secrets.LICENSE_KEY }} + echo "TAG_NAME=$(date +"%Y.%m.%d")" >> $GITHUB_ENV - name: Push to "download" branch run: | @@ -38,6 +39,23 @@ jobs: git config user.email "${{ github.actor }}@users.noreply.github.com" git checkout -b download git add . - git commit -m "$(date +"%Y.%m.%d")" + git commit -m "${{ env.TAG_NAME }}" git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" git push -f origin download + + - name: Upload to Releases + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.TAG_NAME }} + body: ${{ env.TAG_NAME }} + files: upload/*.mmdb + + - name: Remove old Releases + uses: dev-drprasad/delete-older-releases@v0.2.0 + with: + keep_latest: 2 + delete_tags: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/LICENSE b/.github/workflows/LICENSE index 5f5f0ed..84b5d3f 100644 --- a/.github/workflows/LICENSE +++ b/.github/workflows/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 P3TERX +Copyright (c) 2020-2021 P3TERX Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal