chore #49
This file contains hidden or 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
| env: # 定义全局变量 | |
| APP_NAME: "three-cesium-links" | |
| name: Deploy to Aliyun | |
| on: | |
| push: | |
| branches: | |
| - main | |
| # 允许你从 Actions 选项卡手动运行此工作流程 | |
| workflow_dispatch: | |
| # 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列 | |
| # 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成 | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| with: | |
| submodules: false # 禁用子模块检查 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: "18" | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Clean and Generate Static Files | |
| run: | | |
| npm run docs:build | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| - name: Deploy to GitHub Pages | |
| env: | |
| GH_TOKEN: ${{ secrets.G_TOKEN }} | |
| run: | | |
| cd .vitepress/dist | |
| git init | |
| git add -A | |
| git commit -m "Create by workflows" | |
| git remote add origin https://${{ secrets.G_TOKEN }}@github.com/OpenThree/three-cesium-links.git | |
| git push origin HEAD:page -f | |
| # 部署到阿里云服务器 | |
| deploy_to_aliyun: | |
| runs-on: ubuntu-latest | |
| needs: build # 确保先完成构建再进行部署 | |
| steps: | |
| - name: Checkout the code | |
| uses: actions/checkout@v3 | |
| - name: Setup SSH | |
| uses: webfactory/ssh-agent@v0.7.0 | |
| with: | |
| ssh-private-key: ${{secrets.SSH_PRIVATE_KEY}} | |
| - name: Deploy to Aliyun Server | |
| run: | | |
| ssh -o StrictHostKeyChecking=no root@101.200.77.126 " | |
| if [ ! -d "/project/${{env.APP_NAME}}" ]; then | |
| cd /project && | |
| git clone git@github.com:OpenThree/${{env.APP_NAME}}.git | |
| fi && | |
| cd /project/${{env.APP_NAME}} && | |
| git pull origin main && | |
| # 执行你想要的部署命令,比如构建项目、重启服务等 | |
| npm install && | |
| npm run docs:build2 && | |
| if [ ! -d "/nico/nginx/html/openthree/${{env.APP_NAME}}" ]; then | |
| mkdir -p /nico/nginx/html/openthree/${{env.APP_NAME}} && | |
| mkdir -p /nico/nginx/html/openthree/nico | |
| fi && | |
| cp -r /project/${{env.APP_NAME}}/.vitepress/dist/* /nico/nginx/html/openthree/${{env.APP_NAME}} | |
| " |