From c9719a0eece5452ad05aa65ac6df354825cf024e Mon Sep 17 00:00:00 2001 From: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Wed, 5 Aug 2020 14:36:20 +0800 Subject: [PATCH] Add GitHub workflow --- .github/workflows/build.yml | 87 +++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9d6793a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,87 @@ +name: Generate DOMAIN-SET for Surge Mac 3 +on: + schedule: + - cron: "30 22 * * *" + push: + branches: + - master + paths-ignore: + - "**/README.md" +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Set variables + run: | + echo "::set-env name=RELEASE_NAME::Released on $(date +%Y%m%d%H%M)" + echo "::set-env name=TAG_NAME::$(date +%Y%m%d%H%M)" + echo "::set-env name=v2fly_icloud::https://raw.githubusercontent.com/v2fly/domain-list-community/release/icloud.txt" + echo "::set-env name=v2fly_apple::https://raw.githubusercontent.com/v2fly/domain-list-community/release/apple.txt" + echo "::set-env name=Loyalsoldier_reject::https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/reject-list.txt" + echo "::set-env name=Loyalsoldier_proxy::https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/proxy-list.txt" + echo "::set-env name=Loyalsoldier_direct::https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/direct-list.txt" + echo "::set-env name=felixonmars_apple::https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf" + echo "::set-env name=felixonmars_google::https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf" + echo "::set-env name=ipipnet_chinaiplist::https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt" + shell: bash + + - name: Generate icloud.txt file + run: | + curl -sSL ${v2fly_icloud} | grep -E "^full:" | awk -F ':' '{printf "%s\n", $2}' > icloud.txt + curl -sSL ${v2fly_icloud} | grep -E "^domain:" | awk -F ':' '{printf ".%s\n", $2}' >> icloud.txt + + - name: Generate google.txt file + run: | + curl -sSL ${felixonmars_google} | perl -ne '/^server=\/([^\/]+)\// && print ".$1\n"' > google.txt + + - name: Generate apple.txt file + run: | + curl -sSL ${felixonmars_apple} | perl -ne '/^server=\/([^\/]+)\// && print ".$1\n"' > apple.txt + curl -sSL ${v2fly_apple} | grep -E "^full:" | awk -F ':' '{printf "%s\n", $2}' >> apple.txt + curl -sSL ${v2fly_apple} | grep -E "^domain:" | awk -F ':' '{printf ".%s\n", $2}' >> apple.txt + + - name: Generate direct.txt file + run: | + curl -sSL ${Loyalsoldier_direct} | perl -ne '/^([-_a-zA-Z0-9]+(\.[-_a-zA-Z0-9]+)*)/ && print ".$1\n"' > direct.txt + + - name: Generate proxy.txt file + run: | + curl -sSL ${Loyalsoldier_proxy} | perl -ne '/^([-_a-zA-Z0-9]+(\.[-_a-zA-Z0-9]+)*)/ && print ".$1\n"' > proxy.txt + + - name: Generate reject.txt file + run: | + curl -sSL ${Loyalsoldier_reject} | perl -ne '/^([-_a-zA-Z0-9]+(\.[-_a-zA-Z0-9]+)*)/ && print ".$1\n"' > reject.txt + + - name: Generate cncidr.txt file + run: | + curl -sSL ${ipipnet_chinaiplist} | perl -ne '/^(\d{1,3}(\.\d{1,3}){3}\/\d{1,2})/ && print "$1\n"' > cncidr.txt + + - name: Move files to publish directory + run: | + mkdir -p publish + install -p {apple,icloud,google,proxy,direct,reject,cncidr}.txt ./publish/ + + - name: Release and upload assets + uses: softprops/action-gh-release@v1 + with: + name: ${{ env.RELEASE_NAME }} + tag_name: ${{ env.TAG_NAME }} + draft: false + prerelease: false + files: | + ./publish/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Git push assets to "release" branch + run: | + cd publish + git init + git config --local user.name "actions" + git config --local user.email "action@github.com" + git checkout -b release + git add . + git commit -m "${{ env.RELEASE_NAME }}" + git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" + git push -f -u origin release