Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit f35dbcc

Browse files
added CI/CD
1 parent f6f643e commit f35dbcc

File tree

13 files changed

+186
-14
lines changed

13 files changed

+186
-14
lines changed

.github/workflows/gradle.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,36 @@ jobs:
4242
name: build-artifacts
4343
path: |
4444
build/libs/
45+
46+
deploy:
47+
runs-on: ubuntu-latest
48+
needs: [build]
49+
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@v4
53+
54+
- name: Install SSH and SCP
55+
run: sudo apt-get update && sudo apt-get install -y openssh-client sshpass
56+
57+
- name: Download env file
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: build-artifacts
61+
path: .
62+
63+
- name: Upload sources
64+
env:
65+
SSHPASS: ${{ secrets.ROOT_SSH_PASSWORD }}
66+
run: |
67+
sshpass -e scp -o StrictHostKeyChecking=no -r ./mc-oauth-all.jar root@${{ secrets.SERVER_IP }}:/home/andcoolsystems/server
68+
69+
- name: Extract build artifacts on server
70+
env:
71+
SSHPASS: ${{ secrets.ROOT_SSH_PASSWORD }}
72+
run: |
73+
sshpass -e ssh -o StrictHostKeyChecking=no root@${{ secrets.SERVER_IP }} << 'EOF'
74+
cd /home/andcoolsystems/server
75+
docker compose build
76+
docker compose up -d
77+
EOF

Dockerfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
FROM openjdk:17-jdk-slim
1+
FROM openjdk:21
22
WORKDIR /app
33

44
COPY . .
55

6-
CMD ["java", "-jar", "test_auth.jar"]
7-
8-
EXPOSE 8089
9-
EXPOSE 25565
6+
CMD ["java", "-jar", "mc-oauth-all.jar"]

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group = "ru.andcool"
7-
version = "1.0-SNAPSHOT"
7+
version = ""
88

99
repositories {
1010
mavenCentral()

config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"PLAYERS_MAX": 0,
3+
"PORT_SERVER": 25565,
4+
"SERVER_ID": "mc-oauth",
5+
"PROTOCOL_VERSION": -1,
6+
"MOTD": "",
7+
"SERVER_VERSION": "1.20.4",
8+
"PLAYERS_NOW": 0,
9+
"PORT_API": 8089
10+
}

docker-compose.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: "3"
2+
3+
services:
4+
mc-oauth:
5+
container_name: mc-oauth
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
restart: always
10+
ports:
11+
- 25565:25565
12+
networks:
13+
- nginx
14+
15+
networks:
16+
nginx:
17+
external: true
18+
name: nginx

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
rootProject.name = "test_auth"
1+
rootProject.name = "mc-oauth"
22

src/main/java/com/andcool/config/UserConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static void save() {
3636
Files.createDirectories(configFile.toPath().getParent());
3737
Files.writeString(configFile.toPath(), jsonConfig.toString(4));
3838
} catch (IOException e) {
39-
OAuthServer.logger.log(Level.ERROR, e.toString());
39+
OAuthServer.logger.log(Level.DEBUG, e.toString());
4040
}
4141
}
4242

src/main/java/com/andcool/handlers/Encryption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public Encryption(SecretKey sharedSecret) {
2727
encodeBuf = new CryptBuf(Cipher.ENCRYPT_MODE, sharedSecret);
2828
decodeBuf = new CryptBuf(Cipher.DECRYPT_MODE, sharedSecret);
2929
} catch (GeneralSecurityException e) {
30-
OAuthServer.logger.log(Level.ERROR, e.toString());
30+
OAuthServer.logger.log(Level.DEBUG, e.toString());
3131
throw new AssertionError("Failed to initialize encrypted channel", e);
3232
}
3333
}

src/main/java/com/andcool/handlers/EncryptionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static void handleEncryptionResponse(ChannelHandlerContext ctx, ByteBuf i
4848
byte[] verifyToken = rsaCipher.doFinal(encryptedVerifyToken);
4949

5050
if (!Arrays.equals(OAuthServer.VERIFY_TOKEN, verifyToken)) {
51-
OAuthServer.logger.log(Level.ERROR, "Invalid verify token");
51+
OAuthServer.logger.log(Level.DEBUG, "Invalid verify token");
5252
SessionHandler.disconnect(ctx, "Error while encryption!");
5353
return;
5454
} else {
@@ -81,7 +81,7 @@ public static void handleEncryptionResponse(ChannelHandlerContext ctx, ByteBuf i
8181

8282
OAuthServer.logger.log(Level.INFO, "Created code " + code + " for " + session.nickname);
8383
} catch (IOException | InterruptedException | InvalidKeyException | NoSuchAlgorithmException | BadPaddingException | IllegalBlockSizeException | NoSuchPaddingException | JSONException e) {
84-
OAuthServer.logger.log(Level.ERROR, "Exception in handleEncryptionResponse: " + e.toString());
84+
OAuthServer.logger.log(Level.DEBUG, "Exception in handleEncryptionResponse: " + e.toString());
8585
} finally {
8686
//in.release(); // Освобождение буфера
8787
}

src/main/java/com/andcool/session/SessionHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ protected void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Except
5353
EncryptionHandler.handleEncryptionResponse(ctx, in, session);
5454
}
5555
}
56-
default -> OAuthServer.logger.log(Level.ERROR, "Invalid packet ID: " + packetId);
56+
default -> OAuthServer.logger.log(Level.DEBUG, "Invalid packet ID: " + packetId);
5757
}
5858
}catch (Exception e){
59-
OAuthServer.logger.log(Level.ERROR, e.toString());
59+
OAuthServer.logger.log(Level.DEBUG, e.toString());
6060
}
6161
}
6262

6363
@Override
6464
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws IOException {
6565
disconnect(ctx, "§cInternal server exception");
66-
OAuthServer.logger.log(Level.ERROR, cause.toString());
66+
OAuthServer.logger.log(Level.DEBUG, cause.toString());
6767
}
6868

6969
@Override

0 commit comments

Comments
 (0)