forked from SteamWar/SteamWar
@@ -1,3 +1,5 @@
|
|||||||
|
name: Build
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -30,11 +32,44 @@ jobs:
|
|||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@v6
|
uses: gradle/actions/setup-gradle@v6
|
||||||
with:
|
with:
|
||||||
cache-provider: basic
|
cache-provider: basic
|
||||||
- name: Setup Maven Repository
|
- name: Setup Maven Repository
|
||||||
env:
|
env:
|
||||||
SW_MAVEN_CREDENTIALS: ${{ secrets.SW_MAVEN_CREDENTIALS }}
|
SW_MAVEN_CREDENTIALS: ${{ secrets.SW_MAVEN_CREDENTIALS }}
|
||||||
run: |
|
run: |
|
||||||
echo "$SW_MAVEN_CREDENTIALS" > steamwar.properties
|
echo "$SW_MAVEN_CREDENTIALS" > steamwar.properties
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build
|
run: ./gradlew build --no-daemon
|
||||||
|
|
||||||
|
- name: Stage deploy artifacts
|
||||||
|
if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'version/')) }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
rm -rf deploy
|
||||||
|
mkdir -p deploy
|
||||||
|
|
||||||
|
cp "BauSystem/build/libs/BauSystem-all.jar" "deploy/BauSystem.jar"
|
||||||
|
cp "LegacyBauSystem/build/libs/LegacyBauSystem.jar" "deploy/BauSystem-1.12.jar"
|
||||||
|
cp "FightSystem/build/libs/FightSystem-all.jar" "deploy/FightSystem.jar"
|
||||||
|
cp "KotlinCore/build/libs/KotlinCore-all.jar" "deploy/KotlinCore.jar"
|
||||||
|
cp "TNTLeague/build/libs/TNTLeague.jar" "deploy/TNTLeague.jar"
|
||||||
|
cp "LobbySystem/build/libs/LobbySystem.jar" "deploy/LobbySystem.jar"
|
||||||
|
cp "MissileWars/build/libs/MissileWars.jar" "deploy/MissileWars.jar"
|
||||||
|
cp "Realtime/build/libs/Realtime.jar" "deploy/RealTime.jar"
|
||||||
|
cp "SchematicSystem/build/libs/SchematicSystem-all.jar" "deploy/SchematicSystem.jar"
|
||||||
|
cp "SpigotCore/build/libs/SpigotCore-all.jar" "deploy/SpigotCore.jar"
|
||||||
|
cp "Teamserver/build/libs/Teamserver.jar" "deploy/Builder.jar"
|
||||||
|
cp "TowerRun/build/libs/TowerRun.jar" "deploy/TowerRun.jar"
|
||||||
|
cp "VelocityCore/Persistent/build/libs/Persistent.jar" "deploy/PersistentVelocityCore.jar"
|
||||||
|
cp "VelocityCore/Dependencies/build/libs/Dependencies-all.jar" "deploy/DependenciesVelocityCore.jar"
|
||||||
|
cp "VelocityCore/build/libs/VelocityCore-all.jar" "deploy/VelocityCore.jar"
|
||||||
|
cp "WebsiteBackend/build/libs/WebsiteBackend-all.jar" "deploy/website-api.jar"
|
||||||
|
|
||||||
|
- name: Upload deploy artifacts
|
||||||
|
if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'version/')) }}
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: steamwar-jars
|
||||||
|
path: deploy/
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
name: Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows:
|
||||||
|
- Build
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- 'version/*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
name: Deploy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||||
|
steps:
|
||||||
|
- name: Download deploy artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: steamwar-jars
|
||||||
|
path: deploy
|
||||||
|
run-id: ${{ github.event.workflow_run.id }}
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Resolve deploy target
|
||||||
|
id: target
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
SOURCE_BRANCH: ${{ github.event.workflow_run.head_branch }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [[ "$SOURCE_BRANCH" == "main" ]]; then
|
||||||
|
echo "path=/jars/current" >> "$GITHUB_OUTPUT"
|
||||||
|
elif [[ "$SOURCE_BRANCH" == version/* ]]; then
|
||||||
|
version="${SOURCE_BRANCH#version/}"
|
||||||
|
if [[ ! "$version" =~ ^[A-Za-z0-9._-]+$ ]]; then
|
||||||
|
echo "Unsupported version branch name: ${SOURCE_BRANCH}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "path=/jars/${version}" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "Unsupported deployment branch: ${SOURCE_BRANCH}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Upload jars with scp
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
|
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
|
||||||
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
DEPLOY_PATH: ${{ steps.target.outputs.path }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
: "${DEPLOY_HOST:?Missing DEPLOY_HOST secret}"
|
||||||
|
: "${DEPLOY_USER:?Missing DEPLOY_USER secret}"
|
||||||
|
: "${DEPLOY_SSH_KEY:?Missing DEPLOY_SSH_KEY secret}"
|
||||||
|
|
||||||
|
port="${DEPLOY_PORT:-22}"
|
||||||
|
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
chmod 700 ~/.ssh
|
||||||
|
echo "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key
|
||||||
|
chmod 600 ~/.ssh/deploy_key
|
||||||
|
ssh-keyscan -p "$port" "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p '$DEPLOY_PATH'"
|
||||||
|
scp -i ~/.ssh/deploy_key -P "$port" deploy/* "${DEPLOY_USER}@${DEPLOY_HOST}:$DEPLOY_PATH/"
|
||||||
Reference in New Issue
Block a user