Merge remote-tracking branch 'main/master' #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Gradle Build | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'adopt' | |
java-version: '21' | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts | |
path: | | |
build/libs/ | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install SSH and SCP | |
run: sudo apt-get update && sudo apt-get install -y openssh-client sshpass | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
path: . | |
- name: Upload sources | |
env: | |
SSHPASS: ${{ secrets.ROOT_SSH_PASSWORD }} | |
run: | | |
sshpass -e scp -o StrictHostKeyChecking=no -r ./mc-oauth-all.jar root@${{ secrets.SERVER_IP }}:/home/andcoolsystems/server | |
- name: Deploy to server | |
env: | |
SSHPASS: ${{ secrets.ROOT_SSH_PASSWORD }} | |
run: | | |
sshpass -e ssh -o StrictHostKeyChecking=no root@${{ secrets.SERVER_IP }} << 'EOF' | |
cd /home/andcoolsystems/server | |
docker compose build | |
docker compose up -d | |
EOF |