From 09ce84ab4aeac695970bee92cacd23d2fbcbffec Mon Sep 17 00:00:00 2001 From: cxykevin Date: Sun, 7 Jul 2024 21:11:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=20(#9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.hmtsai.cn/study-area-cn/study-area-cn/pulls/9 --- .gitea/workflows/build.yaml | 63 ++++++++++++++++++++++++++++++++++++- .gitignore | 3 ++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index bd304ad..4529339 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -3,6 +3,68 @@ run-name: Build and Publish book (${{ gitea.actor }}) on: [push] jobs: + Format: + runs-on: ubuntu-latest + steps: + - name: Info + run: echo "OS=${{ runner.os }} NAME=${{ gitea.event_name }} REPO=${{ gitea.repository }} BRANCH=${{ gitea.ref }} ST=${{ job.status }} RUNID=${{ gitea.run_id }}" + - name: Checkout + uses: https://git.hmtsai.cn/actions/checkout@v4 + - name: Cache Node + uses: https://git.hmtsai.cn/actions/cache@v4 + id: cache-node + env: + cache-name: cache-node + with: + key: ${{ runner.os }}-node + path: | + /node + - name: Prepare node + if: ${{ steps.cache-node.outputs.cache-hit != 'true' }} + run: | + git clone https://git.hmtsai.cn/cxykevin/study-area-home-action-deps + mv study-area-home-action-deps/node-$(uname -m).tar.xz study-area-home-action-deps/node.tar.xz + tar xvJf study-area-home-action-deps/node.tar.xz + mv node-*-linux-* /node + export PATH=/node/bin:$PATH + echo $PATH + - name: Get npm root + id: npm_root + run: echo "::set-output name=npmroot::$(npm root -g)" + - name: Cache Node Moudles + id: cache-node-moudles + uses: https://git.hmtsai.cn/actions/cache@v4 + env: + cache-name: cache-node-moudles + with: + key: ${{ runner.os }}-node_moudles + path: | + ${{ steps.npm_root.outputs.npmroot }} + - name: Check node + run: | + node -v + npm -v + - name: Prepare NPM source + run: | + export PATH=/node/bin:$PATH + npm config set registry https://registry.npmmirror.com + - name: npm install + if: ${{ steps.cache-node-moudles.outputs.cache-hit != 'true' }} + run: | + export PATH=/node/bin:$PATH + npm install -g @lint-md/cli + - name: Format + run: | + export PATH=/node/bin:$PATH + lint-md src/**/* --threads=8 --fix --suppress-warnings + - name: Commit files + run: | + git config --global user.name "studyareacn-format-bot" + git config --global user.email "studyareacn-format@noreply.localhost" + git remote set-url origin https://${{ secrets.GIT_USER }}:${{ secrets.GIT_PASSWD }}@git.hmtsai.cn/study-area-cn/study-area-cn + git add . + git commit -m "Auto format" + git push Run: runs-on: ubuntu-latest steps: @@ -66,4 +128,3 @@ jobs: run: | mv book index lftp ${{ secrets.FTP_SITE }} -u ${{ secrets.FTP_USERNAME }},${{ secrets.FTP_PWD }} -e "mirror -R index index" - diff --git a/.gitignore b/.gitignore index 7585238..ee8a37e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ book +node +study-area-home-action-deps +study-area-action-deps