update ci

This commit is contained in:
Neucrack
2022-09-05 16:28:26 +08:00
parent 15865c2058
commit 106ad15b3d
6 changed files with 142 additions and 29 deletions

View File

@@ -1,8 +1,8 @@
# This is a basic workflow to help you get started with Actions
name: CI
name: build_doc_upload
# Controls when the action will run.
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
@@ -35,25 +35,42 @@ jobs:
pip3 install teedoc
ls -al ~/.local/bin/
export PATH=~/.local/bin/:$PATH
echo "== install plugins =="
teedoc install
echo "== start build =="
teedoc build
echo "== build complete =="
out_dir=out`python3 -c 'import json; f=open("site_config.json");config=json.load(f);print(config["site_root_url"])'`
sync_gitee=`pwd`/.github/workflows/sync_gitee.yml
cd $out_dir
mv $out_dir ../
remote_addr=`git remote get-url --push origin`
remote_addr=`echo $remote_addr| awk -F'://' '{print $2}'`
user_name=`git log -1 --pretty=format:'%an'`
user_email=`git log -1 --pretty=format:'%ae'`
echo "== checkout gh-pages branch =="
git fetch origin gh-pages
git checkout gh-pages
git pull origin gh-pages
echo "== upload to cloud server =="
pip3 install qiniu
teedoc-upload --cloud qiniu --bucket ${{ secrets.QINIU_BUCKET }} --access_key ${{ secrets.QINIU_ACCESS_KEY }} --secret_key ${{ secrets.QINIU_SECRET_KEY }} --old ./ ../${out_dir}
echo "== upload to gh-pages for pages service =="
cd ../$out_dir
git init
git config user.name ${{ secrets.GIT_NAME }}
git config user.email ${{ secrets.GIT_EMAIL }}
git remote add upstream "git@github.com:${{ secrets.REPO }}.git"
mkdir -p .github/workflows
cp $sync_gitee .github/workflows/
git config user.name ${user_name}
git config user.email ${user_email}
remote_addr=https://${user_name}:${{ secrets.GITHUB_TOKEN }}@${remote_addr}
git remote add origin ${remote_addr}
git add -A
git commit -m "rebuild website ad $GITHUB_REF"
SSHPATH="$HOME/.ssh"
rm -rf "$SSHPATH"
mkdir -p "$SSHPATH"
echo "${{ secrets.ACCESS_KEY }}" > "$SSHPATH/id_rsa"
chmod 600 "$SSHPATH/id_rsa"
sudo sh -c "echo StrictHostKeyChecking no >>/etc/ssh/ssh_config"
git push upstream HEAD:gh-pages --force
git push origin HEAD:gh-pages --force
echo "== push complete =="
# SSHPATH="$HOME/.ssh"
# rm -rf "$SSHPATH"
# mkdir -p "$SSHPATH"
# echo "${{ secrets.ACCESS_KEY }}" > "$SSHPATH/id_rsa"
# chmod 600 "$SSHPATH/id_rsa"
# sudo sh -c "echo StrictHostKeyChecking no >>/etc/ssh/ssh_config"
# git push origin HEAD:gh-pages --force

70
.github/workflows/publish_upload_all.yml vendored Executable file
View File

@@ -0,0 +1,70 @@
# This is a basic workflow to help you get started with Actions
name: build_doc_upload_all
# Controls when the action will run.
on:
# Only allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Runs a set of commands using the runners shell
- name: build doc and push to github pages
run: |
pip3 install setuptools
pip3 install teedoc
ls -al ~/.local/bin/
export PATH=~/.local/bin/:$PATH
echo "== install plugins =="
teedoc install
echo "== start build =="
teedoc build
echo "== build complete =="
out_dir=out`python3 -c 'import json; f=open("site_config.json");config=json.load(f);print(config["site_root_url"])'`
mv $out_dir ../
remote_addr=`git remote get-url --push origin`
remote_addr=`echo $remote_addr| awk -F'://' '{print $2}'`
user_name=`git log -1 --pretty=format:'%an'`
user_email=`git log -1 --pretty=format:'%ae'`
echo "== checkout gh-pages branch =="
git fetch origin gh-pages
git checkout gh-pages
git pull origin gh-pages
echo "== upload to cloud server =="
pip3 install qiniu
teedoc-upload --cloud qiniu --bucket ${{ secrets.QINIU_BUCKET }} --access_key ${{ secrets.QINIU_ACCESS_KEY }} --secret_key ${{ secrets.QINIU_SECRET_KEY }} ../${out_dir}
echo "== upload to gh-pages for pages service =="
cd ../$out_dir
git init
git config user.name ${user_name}
git config user.email ${user_email}
remote_addr=https://${user_name}:${{ secrets.GITHUB_TOKEN }}@${remote_addr}
git remote add origin ${remote_addr}
git add -A
git commit -m "rebuild website ad $GITHUB_REF"
git push origin HEAD:gh-pages --force
echo "== push complete =="
# SSHPATH="$HOME/.ssh"
# rm -rf "$SSHPATH"
# mkdir -p "$SSHPATH"
# echo "${{ secrets.ACCESS_KEY }}" > "$SSHPATH/id_rsa"
# chmod 600 "$SSHPATH/id_rsa"
# sudo sh -c "echo StrictHostKeyChecking no >>/etc/ssh/ssh_config"
# git push origin HEAD:gh-pages --force

View File

@@ -9,7 +9,13 @@ name: sync code to gitee
# branches: [ master ]
# pull_request:
# branches: [ master ]
on: [push, pull_request]
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
# pull_request:
# branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
@@ -37,4 +43,4 @@ jobs:
chmod 600 "$SSHPATH/id_rsa"
sudo sh -c "echo StrictHostKeyChecking no >>/etc/ssh/ssh_config"
git remote add upstream $GITEE_GIT_ADDR
git push upstream --all --force
git push upstream main:main --force