name: build-and-deploy on: push: branches: [main] jobs: build: runs-on: ubuntu-latest steps: # raw checkout:绕开 actions/checkout(服务器拉 github action 不通) # 仓库 public,job 容器经 official-site_default 网络访问 gitea:3000 - name: Checkout run: | git config --global --add safe.directory '*' git clone "http://gitea:3000/${GITHUB_REPOSITORY}.git" . git checkout "${GITHUB_SHA}" - name: Install deps run: npm ci --registry=https://registry.npmmirror.com - name: Build run: npm run build - name: Verify dist run: ls -la dist/ # 部署到 test.shoux.net:job 容器挂载宿主 /var/www/test-shoux-net → /deploy - name: Deploy to test.shoux.net run: | rm -rf /deploy/* cp -r dist/. /deploy/ echo "[deploy] dist -> /deploy (host /var/www/test-shoux-net)" - name: Install ossutil run: | curl -fsSL -o /tmp/ossutilinstall.sh https://gosspublic.alicdn.com/ossutil/install.sh bash /tmp/ossutilinstall.sh - name: Sync to OSS env: OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }} OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }} OSS_ENDPOINT: ${{ secrets.OSS_ENDPOINT }} OSS_BUCKET: ${{ secrets.OSS_BUCKET }} run: bash scripts/deploy-oss.sh