-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (94 loc) · 3.39 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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 }}