Files
file-online-preview/.github/workflows/master-auto-deploy.yml
2026-04-11 16:14:01 +08:00

77 lines
2.2 KiB
Java

name: Master Auto Deploy
on:
push:
branches: [ master ]
workflow_dispatch:
concurrency:
group: master-auto-deploy-production
cancel-in-progress: false
permissions:
contents: read
actions: read
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: temurin
cache: maven
- name: Build with Maven
run: mvn -B package -Dmaven.test.skip=true --file pom.xml
- name: Upload server jar artifact
uses: actions/upload-artifact@v4
with:
name: kkfileview-server-jar
path: server/target/kkFileView-*.jar
retention-days: 7
deploy-windows:
needs: build
runs-on: ubuntu-22.04
env:
GITHUB_REPOSITORY_NAME: ${{ github.repository }}
GITHUB_RUN_ID_VALUE: ${{ github.run_id }}
KK_DEPLOY_ARTIFACT_TOKEN: ${{ secrets.KK_DEPLOY_ARTIFACT_TOKEN }}
KK_DEPLOY_HOST: ${{ secrets.KK_DEPLOY_HOST }}
KK_DEPLOY_PORT: ${{ secrets.KK_DEPLOY_PORT }}
KK_DEPLOY_USERNAME: ${{ secrets.KK_DEPLOY_USERNAME }}
KK_DEPLOY_PASSWORD: ${{ secrets.KK_DEPLOY_PASSWORD }}
KK_DEPLOY_ROOT: ${{ secrets.KK_DEPLOY_ROOT }}
KK_DEPLOY_HEALTH_URL: ${{ secrets.KK_DEPLOY_HEALTH_URL }}
KK_DEPLOY_ARTIFACT_NAME: kkfileview-server-jar
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install WinRM dependencies
run: pip install pywinrm
- name: Validate deploy secrets
run: |
test -n "$KK_DEPLOY_ARTIFACT_TOKEN" || (echo "Missing secret: KK_DEPLOY_ARTIFACT_TOKEN" && exit 1)
test -n "$KK_DEPLOY_HOST" || (echo "Missing secret: KK_DEPLOY_HOST" && exit 1)
test -n "$KK_DEPLOY_USERNAME" || (echo "Missing secret: KK_DEPLOY_USERNAME" && exit 1)
test -n "$KK_DEPLOY_PASSWORD" || (echo "Missing secret: KK_DEPLOY_PASSWORD" && exit 1)
- name: Deploy to Windows server
run: python .github/scripts/deploy_windows_winrm.py