Pull and Build #1305
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pull and Build | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- 'README.md' | |
- 'data/*' | |
- 'LICENSE' | |
jobs: | |
pull: | |
name: Pull felixonmars/dnsmasq-china-list | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set variables | |
run: | | |
echo "RELEASE_NAME=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV | |
echo "CHINA_DOMAINS_URL=https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf" >> $GITHUB_ENV | |
echo "GOOGLE_DOMAINS_URL=https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf" >> $GITHUB_ENV | |
echo "APPLE_DOMAINS_URL=https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf" >> $GITHUB_ENV | |
shell: bash | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
- name: Create `accelerated-domains.china`, `google.china` and `apple.china` lists | |
run: | | |
curl -sSL "${CHINA_DOMAINS_URL}" | awk -F '/' '{print $2}' > data/accelerated-domains.china | |
curl -sSL "${GOOGLE_DOMAINS_URL}" | awk -F '/' '{print $2}' > data/google.china | |
curl -sSL "${APPLE_DOMAINS_URL}" | awk -F '/' '{print $2}' > data/apple.china | |
- name: Configuration environment | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Dct Mei" | |
- name: Git push assets to "master" branch | |
continue-on-error: true | |
run: | | |
git add data/ | |
git commit -m "${{ env.RELEASE_NAME }}" | |
git push origin master | |
build: | |
name: Build china-list.dat | |
needs: pull | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.18 | |
- name: Set variables | |
run: | | |
echo "RELEASE_NAME=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV | |
echo "TAG_NAME=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV | |
shell: bash | |
- name: Checkout codebase | |
uses: actions/checkout@v3 | |
with: | |
path: code | |
- name: Build china-list.dat file | |
run: | | |
cd code/ || exit 1 | |
git pull --rebase | |
go run ./ --outputdir=../ | |
cd ../ && rm -rf code/ | |
- name: Generate china-list.dat sha256 hash | |
run: | | |
sha256sum china-list.dat > china-list.dat.sha256sum | |
- name: Generate XZ | |
run: | | |
xz -z -9 -k china-list.dat | |
sha256sum china-list.dat.xz > china-list.dat.xz.sha256sum | |
- name: Configuration environment | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Dct Mei" | |
- name: Git push assets to "release" branch | |
run: | | |
git init | |
git checkout -b release | |
git add china-list.dat* | |
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 | |
- name: Release and upload assets | |
uses: softprops/action-gh-release@v1 | |
with: | |
draft: false | |
prerelease: false | |
files: | | |
china-list.dat* | |
name: ${{ env.RELEASE_NAME }} | |
tag_name: ${{ env.TAG_NAME }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |