Compare commits
2 Commits
2bbc6c6011
...
0a56bef53d
Author | SHA1 | Date | |
---|---|---|---|
0a56bef53d | |||
6eb13e18eb |
13
src/main/java/cc/fascinated/piaservers/common/Config.java
Normal file
13
src/main/java/cc/fascinated/piaservers/common/Config.java
Normal file
@ -0,0 +1,13 @@
|
||||
package cc.fascinated.piaservers.common;
|
||||
|
||||
public class Config {
|
||||
|
||||
/**
|
||||
* Are we in production?
|
||||
*
|
||||
* @return If we are in production
|
||||
*/
|
||||
public static boolean isProduction() {
|
||||
return System.getenv().containsKey("ENVIRONMENT") && System.getenv("ENVIRONMENT").equals("production");
|
||||
}
|
||||
}
|
@ -12,22 +12,22 @@ public class GitUtils {
|
||||
*/
|
||||
public static void commitFiles(String message, Path... files) {
|
||||
System.out.println("Committing files");
|
||||
if (System.getenv("ENVIRONMENT").equals("production")) {
|
||||
if (Config.isProduction()) {
|
||||
runCommand("git", "config", "--global", "user.email", "liam+pia-servers-ci@fascinated.cc");
|
||||
runCommand("git", "config", "--global", "user.name", "PIA Servers CI");
|
||||
}
|
||||
for (Path file : files) {
|
||||
runCommand("git", "add", file.toAbsolutePath().toString());
|
||||
}
|
||||
runCommand("git", "commit", "-m", message);
|
||||
runCommand("git", "push", "https://pia-servers-ci:%s@git.fascinated.cc/Fascinated/PIA-Servers".formatted(System.getenv("AUTH_TOKEN")));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the repository
|
||||
*/
|
||||
public static void cloneRepo() {
|
||||
if (System.getenv("ENVIRONMENT").equals("production")) {
|
||||
if (Config.isProduction()) {
|
||||
System.out.println("Cloning repository");
|
||||
runCommand("git", "clone", "https://git.fascinated.cc/Fascinated/PIA-Servers.git");
|
||||
runCommand("mv", "PIA-Servers/.git", ".");
|
||||
|
@ -40,6 +40,7 @@ public class PiaManager {
|
||||
if (SERVERS == null) {
|
||||
SERVERS = new HashSet<>();
|
||||
}
|
||||
System.out.println("Loaded " + SERVERS.size() + " servers from the file");
|
||||
|
||||
GitUtils.cloneRepo(); // Clone the repository
|
||||
|
||||
@ -82,13 +83,13 @@ public class PiaManager {
|
||||
|
||||
// Add the new servers to the list
|
||||
for (PiaServerToken serverToken : piaDomain) {
|
||||
// Add the server to the list
|
||||
PiaServer server = new PiaServer(serverToken.getIp(), serverToken.getRegion(), new Date());
|
||||
SERVERS.add(server);
|
||||
boolean newServer = SERVERS.stream().noneMatch(s -> s.getIp().equals(server.getIp()));
|
||||
boolean newServer = SERVERS.stream().noneMatch(server -> server.getIp().equals(serverToken.getIp()));
|
||||
if (newServer) {
|
||||
newServers++;
|
||||
}
|
||||
|
||||
// Add the server to the list
|
||||
SERVERS.add(new PiaServer(serverToken.getIp(), serverToken.getRegion(), new Date()));
|
||||
}
|
||||
|
||||
// Save the servers to the file
|
||||
|
Reference in New Issue
Block a user