From 62ad6af3ca36482e4ecdfc7779b2c338be2df078 Mon Sep 17 00:00:00 2001 From: idxiu Date: Mon, 26 Dec 2022 10:03:56 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20[=E5=90=8C=E6=AD=A5=E8=87=B3thin?= =?UTF-8?q?=E4=BB=93=E5=BA=93]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sync-thin.yml | 69 +++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/sync-thin.yml diff --git a/.github/workflows/sync-thin.yml b/.github/workflows/sync-thin.yml new file mode 100644 index 00000000..0763cb5a --- /dev/null +++ b/.github/workflows/sync-thin.yml @@ -0,0 +1,69 @@ +name: Sync to thin + +on: + push: + branches: + - main + +jobs: + sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + repository: ${{ github.repository }} + ref: main + + - name: Sync code to thin repo + run: | + # 目标仓库地址 + thin_repo="idxiu/vue3-toimc-admin-thin" + # 设置忽略文件列表 + ignore_files=( + "slim" + "ssh-key" + ".git" + ".github" + ".husky" + ".vscode" + "README.md" + "README-zh_CN.md" + "CHANGELOG.md" + "src/views/components" + "auto-imports.d.ts" + ) + ignore_string="" + # Generate ignore string for rsync + for file in "${ignore_files[@]}"; do + ignore_string+="--exclude=$file " + done + + # Set Git user + git config --global user.email "idxiu.cn@gmail.com" + git config --global user.name "idxiu" + + # Set up ssh key + echo "${{ secrets.ACTION_SYNC_KEY }}" > ssh-key + chmod 600 ssh-key + eval "$(ssh-agent -s)" + ssh-add ssh-key + + # Clone 目标仓库 + git clone https://x-access-token:${{ secrets.SYNC_TOKEN }}@github.com/$thin_repo slim + + # 同步到目标仓库 + rsync -av --delete $ignore_string . slim + # 提交推送改变文件至目标仓库 + cd slim + # 添加所有文件 + git add -A + # 提交所有文件 + git commit -m "Sync code from source repo" + # 推送文件到远程仓库 + git push + + + +# ACTION_SYNC_KEY ssh 私钥 +# SYNC_TOKEN token +