-
Notifications
You must be signed in to change notification settings - Fork 87
163 lines (140 loc) · 5.46 KB
/
static.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Simple workflow for deploying static content to GitHub Pages
name: Deploy
on:
# Runs on pushes targeting the default branch
push:
branches: [ "master" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
repository_dispatch:
types: [ generate-gh-pages ]
schedule:
- cron: "*/10 * * * *"
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
deployments: write
# Allow one concurrent deployment
concurrency:
group: event-${{ github.event_name }} # So UT won't be interrupted by cronjobs
cancel-in-progress: true # Avoid batch pending when one job hangs
jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
env:
TOKENIZERS_PARALLELISM: false
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: My Host
run: |
sudo apt install -y -qq moreutils # https://unix.stackexchange.com/questions/26728/prepending-a-timestamp-to-each-line-of-output-from-a-command
echo -e "free -h:\n`free -h`" | ts
echo
sudo rm -rf /usr/local/lib/android & # release about 12 GB, cost 1min
sudo rm -rf /usr/share/dotnet & # release about 1 GB, cost 2s
echo -e "df -h:\n`df -h`" | ts
echo
echo "pwd: `pwd`" | ts
echo
echo "nproc: `nproc`" | ts
echo
echo -e "curl -s ifconfig.me/all:\n`curl -s ifconfig.me/all`" | ts
- name: Export vars to env
env:
VARS_JSON: ${{ toJSON(vars) }}
run: |
echo "$VARS_JSON" | jq -r 'keys[] as $k | "\($k)=\(.[$k])"' >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4.3.0
with:
python-version: 3.9
# cache: 'pip'
# https://blog.allenai.org/python-caching-in-github-actions-e9452698e98d
- name: Python Runtime Cache
id: python-runtime-cache
uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}
- name: Huggingface Model Cache
id: huggingface-model-cache
uses: actions/cache@v3
with:
path: ~/.cache/huggingface/hub/models*
key: ${{ runner.os }}-huggingface
# - name: LLaMA 2 model
# run: |
# mkdir -p ~/.cache/huggingface/hub/
# ls -alh ~/.cache/huggingface/hub/
# curl -L -o ~/.cache/huggingface/hub/models_llama-2-7b-chat.Q6_K.gguf -z ~/.cache/huggingface/hub/models_llama-2-7b-chat.Q6_K.gguf https://huggingface.co/TheBloke/Llama-2-7b-Chat-GGUF/resolve/main/llama-2-7b-chat.Q6_K.gguf
- name: Install Python Dependencies
run: pip install --upgrade -r requirements.txt
- name: Download Page Artifact
uses: dawidd6/action-download-artifact@v3
with:
name: 'github-pages'
path: 'output'
workflow_conclusion: success
if_no_artifact_found: warn # tolerate long time failure, that all artifacts are expired
- name: Extract Page Artifact
if: ${{ hashFiles('output/artifact.tar') != '' }}
run: |
tar -xf output/artifact.tar -C output
rm output/artifact.tar
rm output/image/.gitignore
echo -e "df -h:\n`df -h`"
- name: Unit Test
run: make test
if: ${{ github.event_name == 'push' }}
env:
COZE_API_ENDPOINT: ${{ secrets.COZE_API_ENDPOINT }}
COZE_API_KEY: ${{ secrets.COZE_API_KEY }}
COZE_BOT_ID: ${{ secrets.COZE_BOT_ID }}
- name: Generate Daily Page
run: make gh_daily_page
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
SYSLOG_ADDRESS: ${{ secrets.SYSLOG_ADDRESS }}
COZE_API_ENDPOINT: ${{ secrets.COZE_API_ENDPOINT }}
COZE_API_KEY: ${{ secrets.COZE_API_KEY }}
COZE_BOT_ID: ${{ secrets.COZE_BOT_ID }}
if: ${{ github.event_name == 'push' || endswith(github.run_id, '3') || endswith(github.run_id, '6') || endswith(github.run_id, '9') }}
- name: Generate Home Page
run: make gh_home_page
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
SYSLOG_ADDRESS: ${{ secrets.SYSLOG_ADDRESS }}
COZE_API_ENDPOINT: ${{ secrets.COZE_API_ENDPOINT }}
COZE_API_KEY: ${{ secrets.COZE_API_KEY }}
COZE_BOT_ID: ${{ secrets.COZE_BOT_ID }}
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload Page Artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'output'
retention-days: 7
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
if: ${{ success() }}
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
continue-on-error: true # tolerate cloudflare api failure
if: ${{ success() }}
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: hndigest
directory: 'output'
gitHubToken: ${{ secrets.GITHUB_TOKEN }}