Skip to content

generate-gh-pages #79365

generate-gh-pages

generate-gh-pages #79365

Workflow file for this run

# 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 }}