-
Notifications
You must be signed in to change notification settings - Fork 2
90 lines (71 loc) · 2.12 KB
/
publish-filter.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
name: Publish Filter
on:
workflow_run:
workflows:
- "github-release"
types:
- completed
schedule:
- cron: '0 */6 * * *' # Every 6 hours
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
generate:
runs-on: ubuntu-24.04-arm
timeout-minutes: 15
if: github.ref == 'refs/heads/main'
steps:
- name: Download latest release
run: |
mkdir artifacts && cd artifacts
curl -sL $(curl -s https://api.github.com/repos/henrikwidlund/HostsParser/releases/latest | grep browser_download_url | cut -d\" -f4 | grep 'linux-arm64.tar.gz$') | tar zx
- name: Create public directory
run: mkdir ./public
- name: Create filters
run: |
cat << EOF > temp_script.sh
#!/bin/bash
process_config() {
filename="\$1"
./artifacts/HostsParser "\$1"
CONFIG_FILE=\$(echo "\$filename" | cut -d'/' -f 4)
CONFIG=\${CONFIG_FILE//json/txt}
# Default filter doesn't map to the file name of the config, it's just "filter.txt"
if [[ ! -f "\$CONFIG" ]]; then
CONFIG="filter.txt"
fi
cp "\$CONFIG" ./public/"\$CONFIG"
}
process_config \$1
EOF
chmod +x temp_script.sh
NUM_PROCESSORS=$(nproc)
find ./artifacts/Configurations -name '*.json' -print0 | xargs -0 -I{} -P"$NUM_PROCESSORS" ./temp_script.sh "{}"
rm temp_script.sh
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './public'
deploy:
needs: generate
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
pages: write
id-token: write
actions: read
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4