# This is a basic workflow to help you get started with Actions name: build_doc_upload # Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the main branch push: branches: [ main ] # pull_request: # branches: [ main ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: repository_dispatch: types: [update_maixpy_doc, update_maixcdk_doc] permissions: write-all # 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: # Only run job for specific repository if: github.repository == 'sipeed/sipeed_wiki' # 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: | git fetch --unshallow # fetch all history 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"])'` echo "== clone MaixPy gh-pages ==" git clone https://github.com/sipeed/MaixPy --depth=1 --branch=gh-pages echo "== copy MaixPy dir to out_dir ==" mv MaixPy/maixpy $out_dir rm -rf MaixPy echo "== clone MaixCDK gh-pages ==" git clone https://github.com/sipeed/MaixCDK --depth=1 --branch=gh-pages echo "== copy MaixCDK dir to out_dir ==" mv MaixCDK/maixcdk $out_dir rm -rf MaixCDK 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 status git checkout . git checkout gh-pages git pull origin gh-pages old_out_dir=`pwd` cd ../$out_dir git init git config user.name ${user_name} git config user.email ${user_email} remote_addr="https://Neutree:${{ secrets.GITHUB_TOKEN }}@${remote_addr}" echo "-- user ${user_name}" echo "-- remote addr: ${remote_addr}" git remote add origin "${remote_addr}" git add -A git commit -m "rebuild website ad $GITHUB_REF" echo "== push to gh-pages branch now" git push origin HEAD:gh-pages --force echo "== push complete ==" echo "== upload to cloud server ==" pip3 install cos-python-sdk-v5 teedoc-upload --progress raw --cloud tencent --region ${{ secrets.TENCENT_REGION }} --bucket ${{ secrets.TENCENT_BUCKET }} --secret_id ${{ secrets.TENCENT_SECRET_ID }} --secret_key ${{ secrets.TENCENT_SECRET_KEY }} --old $old_out_dir ./ echo "== upload to gh-pages for pages service ==" # 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