forked from suiyun39/pac-auto-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (82 loc) · 3.24 KB
/
ci.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
95
96
97
98
99
100
name: CI
on:
schedule:
- cron: "0 22 * * 6"
push:
branches:
- master
paths:
- '.github/workflows/*.yml'
- 'rules.txt'
pull_request:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Set variables
run: |
echo "RELEASE_NAME=update on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Upgrade pip and install dependencies
run: |
python -m pip install --upgrade pip
pip install genpac
- name: Get current time
uses: josStorer/get-current-time@v2
id: time
with:
format: yyyy-MM-DD
- name: Download GFWLIST file
run: curl -O https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt
- name: Force commit changes to gfwlist.txt
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add gfwlist.txt
git commit -m "chore: ${{ steps.time.outputs.formattedTime }} force update ./gfwlist.txt" || echo "No changes to commit"
- name: Download AWAvenue-Ads-Rule file
run: curl -O https://raw.githubusercontent.com/TG-Twilight/AWAvenue-Ads-Rule/main/AWAvenue-Ads-Rule.txt
- name: Force commit changes to AWAvenue-Ads-Rule.txt
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add AWAvenue-Ads-Rule.txt
git commit -m "chore: ${{ steps.time.outputs.formattedTime }} force update ./AWAvenue-Ads-Rule.txt" || echo "No changes to commit"
- name: Generate configuration files
run: |
mkdir -p output
genpac --format=pac --pac-proxy "__PROXY__" --gfwlist-local='./gfwlist.txt' --user-rule-from './rules.txt,./AWAvenue-Ads-Rule.txt' -o ./pac/pac.txt
- name: Commit changes to pac.txt
uses: EndBug/add-and-commit@v9
if: github.event_name != 'pull_request'
with:
message: "chore: ${{ steps.time.outputs.formattedTime }} update ./pac/pac.txt"
add: ./pac/pac.txt
author_name: "github-actions[bot]"
author_email: "github-actions[bot]@users.noreply.github.com"
- name: Delete previous release and tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
previous_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
if [ -n "$previous_tag" ]; then
echo "Deleting previous tag: $previous_tag"
git push --delete origin $previous_tag
gh release delete $previous_tag --repo $GITHUB_REPOSITORY --yes
fi
- name: Release and upload assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
release_name: ${{ env.RELEASE_NAME }}
tag: ${{ env.TAG_NAME }}
file_glob: true
file: ./pac/*