This commit is contained in:
2025-11-27 12:51:07 +01:00
parent 913e0dfcc1
commit 15a4936310

View File

@@ -6,51 +6,25 @@ on:
- main - main
jobs: jobs:
build: build_and_deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: maven:3.9.6-eclipse-temurin-17
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install Maven
run: |
apt-get update
apt-get install -y maven
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: maven
- name: Build with Maven - name: Build with Maven
run: mvn -B clean package run: mvn -B clean package
- name: Upload artifact - name: Copy jar to server
uses: actions/upload-artifact@v4
with:
name: auction
path: target/*.jar
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: auction
- name: Copy to server
uses: appleboy/scp-action@v0.1.7 uses: appleboy/scp-action@v0.1.7
with: with:
host: ${{ secrets.SERVER_IP }} host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }} username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }} key: ${{ secrets.SERVER_SSH_KEY }}
source: "*.jar" source: "target/*.jar"
target: "/opt/auction/app.jar" target: "/opt/auction/app.jar"
- name: Restart service - name: Restart service
@@ -61,4 +35,3 @@ jobs:
key: ${{ secrets.SERVER_SSH_KEY }} key: ${{ secrets.SERVER_SSH_KEY }}
script: | script: |
sudo systemctl restart auction sudo systemctl restart auction
echo "Deployment complete"