107 lines
3.3 KiB
YAML
107 lines
3.3 KiB
YAML
name: The Workflow
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- script
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
ci:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Set up Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- name: Run test suite
|
|
run: bun test META.test.js workflow.test.js
|
|
|
|
run:
|
|
runs-on: ubuntu-latest
|
|
needs: ci
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Set up Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- name: Validate runnable scenarios
|
|
run: bun run run
|
|
|
|
purge-dns-cache:
|
|
runs-on: ubuntu-latest
|
|
needs: run
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Purge CDN cache
|
|
run: |
|
|
for file in $(ls); do
|
|
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@script/${file}"
|
|
done
|
|
|
|
generate-config:
|
|
runs-on: ubuntu-latest
|
|
needs: run
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
- name: Set up Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- name: Generate YAML configuration
|
|
run: |
|
|
mkdir -p publish
|
|
bun run generate
|
|
cat > publish/META.yaml << 'EOL'
|
|
proxy-providers-defaults: &ppd
|
|
type: http
|
|
interval: 86400
|
|
health-check:
|
|
enable: true
|
|
url: "https://www.gstatic.com/generate_204"
|
|
interval: 300
|
|
filter: "^(?!.*(群|邀请|返利|循环|官网|客服|网站|网址|获取|订阅|流量|到期|机场|下次|版本|官址|备用|过期|已用|联系|邮箱|工单|贩卖|通知|倒卖|防止|国内|地址|频道|无法|说明|使用|提示|特别|访问|支持|教程|关注|更新|作者|加入|USE|USED|TOTAL|EXPIRE|EMAIL|Panel|Channel|Author))"
|
|
proxy-providers:
|
|
Provider A:
|
|
<<: *ppd
|
|
url: "https://the.url.of/A.yaml"
|
|
override:
|
|
additional-prefix: "[A] "
|
|
Provider B:
|
|
<<: *ppd
|
|
url: "https://the.url.of/B.yaml"
|
|
override:
|
|
additional-prefix: "[B] "
|
|
Provider C:
|
|
<<: *ppd
|
|
url: "https://the.url.of/C.yaml"
|
|
override:
|
|
additional-prefix: "[C] "
|
|
EOL
|
|
cat META.yaml >> publish/META.yaml
|
|
- name: Push to config branch
|
|
run: |
|
|
cd publish
|
|
git init
|
|
git config --local user.name "github-actions[bot]"
|
|
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git checkout -b config
|
|
git add .
|
|
git commit -m "Update YAML configuration"
|
|
git remote add origin "https://github-actions[bot]:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
|
|
git push -f origin config
|