diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml deleted file mode 100644 index cb40573..0000000 --- a/.github/workflows/deploy-test.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Deploy to Test Environment - -on: - push: - branches: - - master - - workflow_dispatch: - inputs: - branch: - description: "要部署的分支(默认 master)" - required: false - default: master - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.branch || github.ref_name }} - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: "24" - cache: "npm" - - - name: Install dependencies - run: npm ci - - - name: Build site (test mode) - run: npm run build:test - - - name: Check build artifacts - run: | - test -d ./dist - test "$(ls -A ./dist)" - - - name: Prepare test directory on remote - uses: appleboy/ssh-action@v1.0.0 - with: - host: ${{ secrets.DEPLOY_HOST }} - username: ${{ secrets.DEPLOY_USER }} - key: ${{ secrets.DEPLOY_KEY }} - port: ${{ secrets.DEPLOY_PORT || 22 }} - script: | - TARGET="${{ secrets.TEST_DEPLOY_PATH }}" - if [ -z "$TARGET" ] || [ "$TARGET" = "/" ]; then - echo "Test deploy path is empty or root; aborting" >&2 - exit 1 - fi - mkdir -p "$TARGET" - - - name: Deploy to test directory over SCP - uses: appleboy/scp-action@v0.1.7 - with: - host: ${{ secrets.DEPLOY_HOST }} - username: ${{ secrets.DEPLOY_USER }} - key: ${{ secrets.DEPLOY_KEY }} - port: ${{ secrets.DEPLOY_PORT || 22 }} - source: "./dist/*" - strip_components: 1 - target: ${{ secrets.TEST_DEPLOY_PATH }} - - - name: Report deployment result - uses: appleboy/ssh-action@v1.0.0 - with: - host: ${{ secrets.DEPLOY_HOST }} - username: ${{ secrets.DEPLOY_USER }} - key: ${{ secrets.DEPLOY_KEY }} - port: ${{ secrets.DEPLOY_PORT || 22 }} - script: | - TARGET="${{ secrets.TEST_DEPLOY_PATH }}" - echo "✅ Test environment deployed to: $TARGET" - echo "📁 Files:" - ls -la "$TARGET" | sed 's/^/ /' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8ed3fb7..14d551b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,14 +4,6 @@ on: push: tags: ["v*"] workflow_dispatch: - inputs: - branch: - description: "要部署的分支(默认 master)" - required: false - default: master - -permissions: - contents: write # 同一套线上目录只能同时执行一个发布,避免两个任务互相清理 release。 concurrency: @@ -25,7 +17,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ github.event.inputs.branch || github.ref_name }} + ref: ${{ github.ref_name }} - name: Setup Node.js uses: actions/setup-node@v4 @@ -50,7 +42,7 @@ jobs: if [ "${{ github.event_name }}" = "push" ]; then VERSION="${{ github.ref_name }}" else - BRANCH="${{ github.event.inputs.branch || 'master' }}" + BRANCH="${{ github.ref_name }}" SHORT_SHA=$(git rev-parse --short HEAD) VERSION=$(echo "$BRANCH" | sed 's|/|-|g')-${SHORT_SHA} fi