mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Implement purge cache with Node.js
This commit is contained in:
parent
00117c9863
commit
f03049a8dd
21
.github/scripts/purge-cache.js
vendored
Normal file
21
.github/scripts/purge-cache.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
const { compilationInfo } = require('../../webpack/compilation-info')
|
||||
const https = require('https')
|
||||
|
||||
const files = [
|
||||
'dist/bilibili-evolved.preview.user.js',
|
||||
'dist/bilibili-evolved.user.js',
|
||||
]
|
||||
|
||||
files.forEach(file => {
|
||||
const path = `/gh/the1812/Bilibili-Evolved@${compilationInfo.branch}/${file}`
|
||||
console.log('path:', path)
|
||||
const request = https.request({
|
||||
hostname: 'purge.jsdelivr.net',
|
||||
path,
|
||||
method: 'GET',
|
||||
}, response => {
|
||||
response.on('data', data => console.log(data))
|
||||
})
|
||||
request.on('error', error => console.error(error))
|
||||
request.end()
|
||||
})
|
||||
26
.github/scripts/purge_cache.py
vendored
26
.github/scripts/purge_cache.py
vendored
@ -1,26 +0,0 @@
|
||||
import os, requests
|
||||
|
||||
|
||||
def get_file_list(folder_dir: str):
|
||||
dir_list = os.listdir(folder_dir)
|
||||
f_list = []
|
||||
for d in dir_list:
|
||||
sub_dir = os.path.join(folder_dir, d)
|
||||
if os.path.isfile(sub_dir):
|
||||
f_list.append(d)
|
||||
return f_list
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
work_space = os.environ.get('GITHUB_WORKSPACE')
|
||||
file_list = get_file_list(work_space)
|
||||
for file in file_list:
|
||||
# https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@master/dist/*
|
||||
url = f'https://purge.jsdelivr.net/gh/the1812/Bilibili-Evolved/dist/{file}'
|
||||
print(url)
|
||||
print(requests.get(url).text)
|
||||
# https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@master/*
|
||||
url = f'https://purge.jsdelivr.net/gh/the1812/Bilibili-Evolved/{file}'
|
||||
print(url)
|
||||
print(requests.get(url).text)
|
||||
|
||||
10
.github/workflows/debugger-action.yml
vendored
10
.github/workflows/debugger-action.yml
vendored
@ -1,10 +0,0 @@
|
||||
name: debugger-action
|
||||
on: [push, workflow_dispatch]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup Debug Session
|
||||
uses: csexton/debugger-action@master
|
||||
|
||||
18
.github/workflows/purge_cache.yml
vendored
18
.github/workflows/purge_cache.yml
vendored
@ -1,15 +1,21 @@
|
||||
name: Purge Cache
|
||||
|
||||
on: [push, workflow_dispatch]
|
||||
on:
|
||||
push:
|
||||
branches: [ master, preview ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
speed:
|
||||
pruge:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
python-version: 3.x
|
||||
- run: pip install requests
|
||||
- run: python ./.github/scripts/purge_cache.py
|
||||
node-version: '16'
|
||||
|
||||
- name: Send Purge Request
|
||||
run: node .github/scripts/purge-cache.js
|
||||
|
||||
Loading…
Reference in New Issue
Block a user