fix: cicd-调整
Some checks failed
JT808 CI/CD / build-and-deploy (push) Failing after 1m5s

This commit is contained in:
lzh
2025-12-12 15:24:41 +08:00
parent 6bb6cc4b4c
commit 0b8b03adf4
2 changed files with 21 additions and 38 deletions

View File

@@ -8,49 +8,33 @@ on:
jobs:
build-and-deploy:
runs-on: xw-runner
env:
REGISTRY_URL: ${{ secrets.REGISTRY_URL }}
IMAGE_NAME: ${{ secrets.IMAGE_NAME }}
steps:
- name: Checkout code
uses: https://github.com/actions/checkout@v4
- name: Set up JDK 17
uses: https://github.com/actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Build Jar
run: mvn -B clean package -DskipTests
uses: https://gitea.com/actions/checkout@v4
- name: Determine image tag
id: vars
run: |
REGISTRY_URL='${{ secrets.REGISTRY_URL }}'
IMAGE_NAME='${{ secrets.IMAGE_NAME }}'
SHA=$(git rev-parse --short HEAD)
echo "IMAGE_TAG=${REGISTRY_URL}/${IMAGE_NAME}:${SHA}" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Log in to registry
if: ${{ secrets.REGISTRY_USERNAME && secrets.REGISTRY_PASSWORD }}
uses: https://github.com/docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build Jar (in Maven container)
run: |
docker run --rm \
-v "$PWD":/workspace \
-w /workspace \
maven:3.9.9-eclipse-temurin-17 \
mvn -B clean package -DskipTests
- name: Build and push Docker image
uses: https://github.com/docker/build-push-action@v5
with:
context: .
push: true
file: Dockerfile
tags: ${{ steps.vars.outputs.IMAGE_TAG }}
run: |
docker build --pull -t "${{ steps.vars.outputs.IMAGE_TAG }}" .
docker push "${{ steps.vars.outputs.IMAGE_TAG }}"
- name: Deploy to target host
uses: https://github.com/appleboy/ssh-action@v0.1.5
uses: https://gitea.com/appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.DEPLOY_HOST }}
port: ${{ secrets.DEPLOY_PORT }}