Skip to content

build

build #103

Workflow file for this run

name: build
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
push:
branches: [ main ]
jobs:
build:
strategy:
matrix:
platform: [ ubuntu-latest ]
name: Build
runs-on: ${{ matrix.platform }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Get dependencies
run: |
sudo apt-get update -y
\cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python
run: uv python install
- name: Install dependencies
run: |
uv sync --default-index https://pypi.org/simple/
- name: Restore cache lock
id: cache-lock-restore
run: |
if git show-ref --verify --quiet refs/remotes/origin/release; then
git restore --source=origin/release sources/cache.lock || true
fi
- name: Restore cached sources
id: cache-restore
uses: actions/cache/restore@v4
with:
path: runtime/sources
key: cache-sources-${{ hashFiles('**/cache.lock') }}
- name: Sync sources
env:
PYTHONPATH: ${{ env.PYTHONPATH }}:${{ github.workspace }}/src
run: |
uv run src/main.py
date > sources/cache.lock
- name: Save cached sources
id: cache-save
uses: actions/cache/save@v4
with:
path: runtime/sources
key: cache-sources-${{ hashFiles('**/cache.lock') }}
- name: Cleanup
env:
PYTHONPATH: ${{ env.PYTHONPATH }}:${{ github.workspace }}/src
run: |
uv run src/cleanup.py
- name: Commit files
run: |
sudo git config --local user.email "github-actions[bot]@users.noreply.github.com"
sudo git config --local user.name "github-actions[bot]"
sudo git rm --cached --ignore-unmatch -r -f *
sudo git add .
sudo git commit -m "Add sync changes"
sudo git show-ref --verify --quiet refs/heads/release || sudo git checkout -b release
sudo git push -f origin release