CI build once and deploy artifact
Some checks failed
build-and-deploy / deploy (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled

This commit is contained in:
deploy
2026-01-26 17:28:29 +05:30
parent b972563971
commit f015aff2a4

View File

@@ -1,38 +1,54 @@
name: build
name: build-and-deploy
on:
push:
branches: [ "**" ]
pull_request:
branches: [ "**" ]
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 19
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "19"
java-version: "17"
cache: gradle
- name: Build
run: ./gradlew build -x test --no-daemon --info --stacktrace
- name: Force toolchain JDK 17
run: |
if [ -f build.gradle.kts ]; then
sed -i 's/JavaLanguageVersion.of(19)/JavaLanguageVersion.of(17)/' build.gradle.kts
fi
- name: Upload jar
- name: Build (skip tests)
env:
GRADLE_OPTS: "-Dorg.gradle.internal.http.connectionTimeout=60000 -Dorg.gradle.internal.http.socketTimeout=60000"
run: ./gradlew build -x test --no-daemon
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: trisolarisserver-jar
path: build/libs/*.jar
path: build/libs/TrisolarisServer-*-SNAPSHOT.jar
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Trigger deploy webhook
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: trisolarisserver-jar
path: /tmp/trisolarisserver-artifact
- name: Deploy jar and restart
run: |
curl -sS -X POST -H "X-Gitea-Event: push" http://127.0.0.1:9000/hooks/deploy-trisolarisserver
set -e
sudo mkdir -p /opt/deploy/TrisolarisServer/build/libs
sudo cp -f /tmp/trisolarisserver-artifact/*.jar /opt/deploy/TrisolarisServer/build/libs/
sudo systemctl restart TrisolarisServer.service