fix: 长沙市天心区龙湾小学 (resolve #197), 杭州代码部落教育科技有限公司 (resolve #198), 南京一中明发… #244
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate Data | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.x | |
- name: Install Dependencies (Python) | |
run: | | |
python -m pip install --upgrade pip | |
pip install pypinyin requests tqdm | |
- name: Build | |
run: python main.py | |
- name: Rename Files | |
run: | | |
STATIC_SHA512=$(jq -r .sha512 dist/static.info.json) | |
RESULT_SHA512=$(jq -r .sha512 dist/result.info.json) | |
mv dist/static.json dist/static.${STATIC_SHA512:0:7}.json | |
mv dist/result.txt dist/result.${RESULT_SHA512:0:7}.txt | |
ln -s static.info.json dist/static.sha512.json | |
ln -s result.info.json dist/result.sha512.json | |
ln -s static.${STATIC_SHA512:0:7}.json dist/static.json | |
ln -s result.${RESULT_SHA512:0:7}.txt dist/result.txt | |
- name: Deploy to GitHub Pages | |
if: ${{ github.event_name == 'push' && github.repository_owner == 'oierdb-ng' }} | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: dist | |
user_name: BaoshuoBot | |
user_email: bot@baoshuo.ren | |
- name: Deploy to server (Tokyo, JP) | |
if: ${{ github.event_name == 'push' && github.repository_owner == 'oierdb-ng' }} | |
uses: easingthemes/ssh-deploy@v3.0.1 | |
env: | |
ARGS: "-avz --delete" | |
SOURCE: dist/ | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | |
REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
TARGET: ${{ secrets.REMOTE_PATH }} | |
EXCLUDE: .git,.github,.gitlab-ci.yml,.nojekyll | |
- name: Deploy to server (Hong Kong, CN) | |
if: ${{ github.event_name == 'push' && github.repository_owner == 'oierdb-ng' }} | |
uses: easingthemes/ssh-deploy@v3.0.1 | |
env: | |
ARGS: "-avz --delete" | |
SOURCE: dist/ | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST_2 }} | |
REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
TARGET: ${{ secrets.REMOTE_PATH }} | |
EXCLUDE: .git,.github,.gitlab-ci.yml,.nojekyll | |
sync: | |
if: ${{ github.event_name == 'push' && github.repository_owner == 'oierdb-ng' }} | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: gh-pages | |
- name: Checkout renbaoshuo/cdn-sb | |
uses: actions/checkout@v3 | |
with: | |
repository: renbaoshuo/cdn-sb | |
ssh-key: ${{ secrets.CDN_SB_SSH_PRIVATE_KEY }} | |
path: cdn-sb | |
- name: Copy Files | |
run: | | |
STATIC_SHA512=$(jq -r .sha512 static.info.json) | |
RESULT_SHA512=$(jq -r .sha512 result.info.json) | |
rm -rf cdn-sb/public/oier | |
mkdir -p cdn-sb/public/oier | |
cp static.${STATIC_SHA512:0:7}.json cdn-sb/public/oier/static.${STATIC_SHA512:0:7}.json | |
cp result.${RESULT_SHA512:0:7}.txt cdn-sb/public/oier/result.${RESULT_SHA512:0:7}.txt | |
- id: get-commit-sha | |
run: | | |
id="${{ github.sha }}" | |
echo "id=${id:0:7}" >> $GITHUB_OUTPUT | |
- name: Upload | |
run: | | |
cd cdn-sb | |
git config --global user.name BaoshuoBot | |
git config --global user.email bot@baoshuo.dev | |
git add public/oier | |
git commit -m "[OIerDb/${{ steps.get-commit-sha.outputs.id }}] Upload dist on $(date '+%Y-%m-%d %H:%M:%S')" --allow-empty | |
git push |