Skip to content

Commit 04fe942

Browse files
authored
Merge pull request #2929 from objectcomputing/feature-2486/create-new-pipeline-for-updated-env
Convert to newly terraformed development environment
2 parents cf459cc + f007860 commit 04fe942

31 files changed

Lines changed: 447 additions & 274 deletions

.github/workflows/gradle-deploy-develop.yml

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ on:
55
- 'develop'
66
env:
77
HUSKY: 0
8-
PROJECT_ID: ${{ secrets.RUN_PROJECT }}
8+
PROJECT_NUMBER: ${{ secrets.PROJECT_NUM }}
9+
PROJECT_ID: ${{ secrets.PROJECT_ID }}
10+
PROJECT_NAME: ${{ secrets.PROJECT_NAME }}
911
RUN_REGION: us-central1
1012
SERVICE_NAME: checkins-develop
11-
TARGET_URL: https://checkins-develop-832140020593.us-central1.run.app
13+
TARGET_URL: https://checkins-develop.objectcomputing.com
1214
jobs:
1315
test:
1416
runs-on: ubuntu-latest
@@ -42,19 +44,19 @@ jobs:
4244
runs-on: ubuntu-latest
4345
environment:
4446
name: Development
45-
url: ${{ env.TARGET_URL }}
47+
url: ${{ env.TARGET_URL }}/
4648
steps:
4749
- uses: actions/checkout@v4
4850
with:
49-
fetch-depth: 0
51+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
5052
- name: Set up Node LTS
5153
uses: actions/setup-node@v4
5254
with:
5355
node-version: '22'
5456
- name: Set up Temurin 21
5557
uses: actions/setup-java@v4
5658
with:
57-
distribution: 'temurin'
59+
distribution: 'temurin' # See 'Supported distributions' for available options
5860
java-version: 21
5961
- name: Cache Gradle packages
6062
uses: actions/cache@v4
@@ -67,8 +69,15 @@ jobs:
6769
- id: 'auth'
6870
uses: 'google-github-actions/auth@v2'
6971
with:
70-
project_id: 'oci-intern-2019'
71-
workload_identity_provider: 'projects/832140020593/locations/global/workloadIdentityPools/github/providers/my-repo'
72+
project_id: ${{ secrets.PROJECT_ID }}
73+
workload_identity_provider: 'projects/${{secrets.PROJECT_NUM}}/locations/global/workloadIdentityPools/github-wif-pool/providers/github-provider'
74+
service_account: '${{secrets.AUTOMATION_SERVICE_ACCOUNT}}'
75+
- id: 'secrets'
76+
uses: 'google-github-actions/get-secretmanager-secrets@v2'
77+
with:
78+
secrets: |-
79+
cloud_db_connection_name:${{secrets.PROJECT_NUM}}/CLOUD_DB_CONNECTION_NAME
80+
connector_id:${{secrets.PROJECT_NUM}}/CONNECTOR_ID
7281
- name: 'Set up Cloud SDK'
7382
uses: google-github-actions/setup-gcloud@v2
7483
with:
@@ -89,32 +98,27 @@ jobs:
8998
run: |-
9099
gcloud run deploy "$SERVICE_NAME" \
91100
--quiet \
101+
--project "$PROJECT_ID" \
92102
--region "$RUN_REGION" \
93103
--image "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" \
94104
--memory 1Gi \
95-
--add-cloudsql-instances ${{ secrets.DB_CONNECTION_NAME }} \
96-
--set-env-vars "CLOUD_DB_CONNECTION_NAME=${{ secrets.DB_CONNECTION_NAME }}" \
97-
--set-env-vars "DB_NAME=${{ secrets.DB_NAME }}" \
98-
--set-env-vars "DATASOURCES_DEFAULT_PASSWORD=${{ secrets.DB_PASSWORD }}" \
99-
--set-env-vars "DATASOURCES_DEFAULT_USERNAME=${{ secrets.DB_USERNAME }}" \
100-
--set-env-vars "AES_KEY=${{ secrets.AES_KEY }}" \
101-
--set-env-vars "OAUTH_CLIENT_ID=${{ secrets.OAUTH_CLIENT_ID }}" \
102-
--set-env-vars "OAUTH_CLIENT_SECRET=${{ secrets.OAUTH_CLIENT_SECRET }}" \
103-
--set-env-vars "OAUTH_CALLBACK_URI"=${{ secrets.OAUTH_CALLBACK_URI }} \
104-
--set-env-vars "DIRECTORY_ID=${{ secrets.DIRECTORY_ID }}" \
105-
--set-env-vars "SERVICE_ACCOUNT_CREDENTIALS=${{ secrets.SERVICE_ACCOUNT_CREDENTIALS }}" \
106-
--set-env-vars "GSUITE_SUPER_ADMIN=${{ secrets.GSUITE_SUPER_ADMIN }}" \
107-
--set-env-vars "MJ_APIKEY_PUBLIC=${{ secrets.MJ_APIKEY_PUBLIC }}" \
108-
--set-env-vars "MJ_APIKEY_PRIVATE=${{ secrets.MJ_APIKEY_PRIVATE }}" \
109-
--set-env-vars "GIT_HUB_TOKEN=${{ secrets.GIT_HUB_TOKEN }}" \
110-
--set-env-vars "WEB_ADDRESS=${{ env.TARGET_URL }}" \
111-
--set-env-vars "FROM_ADDRESS=no-reply@objectcomputing.com" \
112-
--set-env-vars "FROM_NAME=Check-Ins - DEVELOP" \
113-
--set-env-vars "^@^MICRONAUT_ENVIRONMENTS=dev,cloud,google,gcp" \
114-
--set-env-vars "SLACK_WEBHOOK_URL=${{ secrets.SLACK_WEBHOOK_URL }}" \
115-
--set-env-vars "SLACK_BOT_TOKEN=${{ secrets.SLACK_BOT_TOKEN }}" \
116-
--set-env-vars "SLACK_SIGNING_SECRET=${{ secrets.SLACK_PULSE_SIGNING_SECRET }}" \
117-
--set-env-vars "SLACK_KUDOS_CHANNEL_ID=${{ secrets.SLACK_KUDOS_CHANNEL_ID }}" \
105+
--add-cloudsql-instances ${{steps.secrets.outputs.cloud_db_connection_name }} \
106+
--vpc-connector ${{steps.secrets.outputs.connector_id}} \
107+
--set-secrets "CLOUD_DB_CONNECTION_NAME=CLOUD_DB_CONNECTION_NAME:latest" \
108+
--set-secrets "DB_NAME=DB_NAME:latest" \
109+
--set-secrets "DATASOURCES_DEFAULT_PASSWORD=DATASOURCES_DEFAULT_PASSWORD:latest" \
110+
--set-secrets "DATASOURCES_DEFAULT_USERNAME=DATASOURCES_DEFAULT_USERNAME:latest" \
111+
--set-secrets "AES_KEY=AES_KEY:latest" \
112+
--set-secrets "OAUTH_CLIENT_ID=OAUTH_CLIENT_ID:latest" \
113+
--set-secrets "OAUTH_CLIENT_SECRET=OAUTH_CLIENT_SECRET:latest" \
114+
--set-secrets "GSUITE_SUPER_ADMIN=GSUITE_SUPER_ADMIN:latest" \
115+
--set-secrets "SERVICE_ACCOUNT_CREDENTIALS=SERVICE_ACCOUNT_CREDENTIALS:latest" \
116+
--set-secrets "WEB_ADDRESS=WEB_ADDRESS:latest" \
117+
--set-secrets "MICRONAUT_ENVIRONMENTS=MICRONAUT_ENVIRONMENTS:latest" \
118+
--set-secrets "SLACK_WEBHOOK_URL=SLACK_WEBHOOK_URL:latest" \
119+
--set-secrets "SLACK_BOT_TOKEN=SLACK_BOT_TOKEN:latest" \
120+
--set-secrets "SLACK_SIGNING_SECRET=SLACK_SIGNING_SECRET:latest" \
121+
--set-secrets "SLACK_KUDOS_CHANNEL_ID=SLACK_KUDOS_CHANNEL_ID:latest" \
118122
--platform "managed" \
119123
--max-instances 2 \
120124
--allow-unauthenticated

server/src/main/java/com/objectcomputing/checkins/notifications/email/MailJetFactory.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
import com.mailjet.client.MailjetClient;
55

66
import com.mailjet.client.resource.Emailv31;
7+
import com.objectcomputing.checkins.exceptions.NotFoundException;
8+
import com.objectcomputing.checkins.services.settings.SettingOption;
9+
import com.objectcomputing.checkins.services.settings.SettingsServices;
710
import io.micronaut.context.annotation.Bean;
811
import io.micronaut.context.annotation.Factory;
912

13+
import jakarta.inject.Inject;
1014
import jakarta.inject.Named;
1115
import jakarta.inject.Singleton;
1216

@@ -17,13 +21,33 @@ public class MailJetFactory {
1721
public static final String MJML_FORMAT = "mjml";
1822
public static final String TEXT_FORMAT = "text";
1923

24+
@Inject
25+
SettingsServices settingsServices;
26+
2027
@Bean
2128
MailjetClient getClient() {
29+
30+
String mj_apikey_public;
31+
String mj_apikey_private;
32+
33+
try {
34+
mj_apikey_public = settingsServices.systemFindByName(SettingOption.MJ_APIKEY_PUBLIC.name()).getValue();
35+
} catch (NotFoundException e) {
36+
mj_apikey_public = "";
37+
}
38+
try {
39+
mj_apikey_private = settingsServices.systemFindByName(SettingOption.MJ_APIKEY_PRIVATE.name()).getValue();
40+
} catch (NotFoundException e) {
41+
mj_apikey_private = "";
42+
}
43+
44+
45+
2246
return new MailjetClient(
2347
ClientOptions
2448
.builder()
25-
.apiKey(System.getenv("MJ_APIKEY_PUBLIC"))
26-
.apiSecretKey(System.getenv("MJ_APIKEY_PRIVATE"))
49+
.apiKey(mj_apikey_public)
50+
.apiSecretKey(mj_apikey_private)
2751
.build()
2852
);
2953
}

server/src/main/java/com/objectcomputing/checkins/notifications/email/MailJetSender.java

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import com.mailjet.client.resource.Emailv31;
88
import ch.digitalfondue.mjml4j.Mjml4j;
99
import com.objectcomputing.checkins.exceptions.BadArgException;
10+
import com.objectcomputing.checkins.exceptions.NotFoundException;
11+
import com.objectcomputing.checkins.services.settings.SettingOption;
12+
import com.objectcomputing.checkins.services.settings.SettingsServices;
1013
import io.micronaut.context.annotation.Prototype;
1114
import io.micronaut.context.annotation.Requires;
1215
import org.json.JSONArray;
@@ -19,27 +22,40 @@
1922
import java.util.List;
2023

2124
@Prototype
22-
@Requires(bean = MailJetConfiguration.class)
2325
public class MailJetSender implements EmailSender {
2426
public static final String MJMLPART = "MJMLPART";
2527

2628
private static final Logger LOG = LoggerFactory.getLogger(MailJetSender.class);
2729
private final MailjetClient client;
30+
private final SettingsServices settingsServices;
2831

2932
public static final int MAILJET_RECIPIENT_LIMIT = 49;
3033

31-
private final String fromAddress;
32-
private final String fromName;
3334
private String emailFormat;
3435

36+
private String getFromAddress() {
37+
try {
38+
return settingsServices.systemFindByName(SettingOption.FROM_ADDRESS.name()).getValue();
39+
} catch (NotFoundException e) {
40+
return "";
41+
}
42+
}
43+
44+
private String getFromName() {
45+
try {
46+
return settingsServices.systemFindByName(SettingOption.FROM_NAME.name()).getValue();
47+
} catch (NotFoundException e) {
48+
return "";
49+
}
50+
}
51+
3552
public MailJetSender(
3653
MailjetClient client,
37-
MailJetConfiguration configuration
54+
SettingsServices settingsServices
3855
) {
3956
this.client = client;
40-
this.fromAddress = configuration.getFromAddress();
41-
this.fromName = configuration.getFromName();
4257
this.emailFormat = Emailv31.Message.HTMLPART;
58+
this.settingsServices = settingsServices;
4359
}
4460

4561
/**
@@ -82,10 +98,23 @@ public static List<JSONArray> getEmailBatches(String... recipients) {
8298
*/
8399
@Override
84100
public void sendEmail(String fromName, String fromAddress, String subject, String content, String... recipients) {
85-
if(fromName == null) fromName = this.fromName;
86-
if(fromAddress == null) fromAddress = this.fromAddress;
101+
if(fromName == null) fromName = getFromName();
102+
if(fromAddress == null) fromAddress = getFromAddress();
103+
104+
String mj_apikey_public;
105+
String mj_apikey_private;
106+
try {
107+
mj_apikey_public = settingsServices.systemFindByName(SettingOption.MJ_APIKEY_PUBLIC.name()).getValue();
108+
} catch (NotFoundException e) {
109+
mj_apikey_public = "";
110+
}
111+
try {
112+
mj_apikey_private = settingsServices.systemFindByName(SettingOption.MJ_APIKEY_PRIVATE.name()).getValue();
113+
} catch (NotFoundException e) {
114+
mj_apikey_private = "";
115+
}
87116

88-
if(System.getenv("MJ_APIKEY_PUBLIC") == null || System.getenv("MJ_APIKEY_PRIVATE") == null) {
117+
if(mj_apikey_public == "" || mj_apikey_private == "") {
89118
LOG.error("API key(s) are missing for MailJetSender");
90119
return;
91120
}
@@ -117,7 +146,7 @@ public void sendEmail(String fromName, String fromAddress, String subject, Strin
117146
List<JSONArray> failedBatches = new ArrayList<>();
118147
final JSONArray to =
119148
new JSONArray()
120-
.put(new JSONObject().put("Email", this.fromAddress));
149+
.put(new JSONObject().put("Email", fromAddress));
121150
emailBatches.forEach((recipientList) -> {
122151
try {
123152
send(sender, to, recipientList,

server/src/main/java/com/objectcomputing/checkins/security/GoogleServiceConfiguration.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import io.micronaut.validation.validator.constraints.ConstraintValidator;
88
import jakarta.inject.Singleton;
99
import jakarta.validation.Constraint;
10-
import jakarta.validation.constraints.NotNull;
1110
import lombok.Getter;
1211
import lombok.Setter;
1312
import org.slf4j.Logger;
@@ -29,9 +28,6 @@ public class GoogleServiceConfiguration {
2928

3029
private static final Logger LOG = LoggerFactory.getLogger(GoogleServiceConfiguration.class);
3130

32-
@NotNull
33-
private String directoryId;
34-
3531
@ValidEncodedGoogleServiceConfiguration
3632
private String encodedValue;
3733

server/src/main/java/com/objectcomputing/checkins/services/file/FileServicesImpl.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.google.api.services.drive.Drive;
66
import com.google.api.services.drive.model.File;
77
import com.google.api.services.drive.model.FileList;
8+
import com.objectcomputing.checkins.exceptions.NotFoundException;
89
import com.objectcomputing.checkins.security.GoogleServiceConfiguration;
910
import com.objectcomputing.checkins.services.checkindocument.CheckinDocument;
1011
import com.objectcomputing.checkins.services.checkindocument.CheckinDocumentServices;
@@ -14,10 +15,11 @@
1415
import com.objectcomputing.checkins.services.memberprofile.MemberProfileServices;
1516
import com.objectcomputing.checkins.services.memberprofile.MemberProfileUtils;
1617
import com.objectcomputing.checkins.services.memberprofile.currentuser.CurrentUserServices;
18+
import com.objectcomputing.checkins.services.settings.SettingOption;
19+
import com.objectcomputing.checkins.services.settings.SettingsServices;
1720
import com.objectcomputing.checkins.util.googleapiaccess.GoogleApiAccess;
1821
import io.micronaut.http.MediaType;
1922
import io.micronaut.http.multipart.CompletedFileUpload;
20-
2123
import jakarta.inject.Singleton;
2224
import org.slf4j.Logger;
2325
import org.slf4j.LoggerFactory;
@@ -38,17 +40,20 @@ public class FileServicesImpl extends FileServicesBaseImpl {
3840

3941
private final GoogleApiAccess googleApiAccess;
4042
private final GoogleServiceConfiguration googleServiceConfiguration;
43+
private SettingsServices settingsServices;
4144

4245
public FileServicesImpl(GoogleApiAccess googleApiAccess,
4346
CheckInServices checkInServices,
4447
CheckinDocumentServices checkinDocumentServices,
4548
MemberProfileServices memberProfileServices,
4649
CurrentUserServices currentUserServices,
47-
GoogleServiceConfiguration googleServiceConfiguration) {
50+
GoogleServiceConfiguration googleServiceConfiguration,
51+
SettingsServices settingsServices) {
4852
super(checkInServices, checkinDocumentServices, memberProfileServices,
4953
currentUserServices);
5054
this.googleApiAccess = googleApiAccess;
5155
this.googleServiceConfiguration = googleServiceConfiguration;
56+
this.settingsServices = settingsServices;
5257
}
5358

5459
@Override
@@ -58,8 +63,8 @@ protected void getCheckinDocuments(
5863
Drive drive = googleApiAccess.getDrive();
5964
validate(drive == null, "Unable to access Google Drive");
6065

61-
String rootDirId = googleServiceConfiguration.getDirectoryId();
62-
validate(rootDirId == null, "No destination folder has been configured. Contact your administrator for assistance.");
66+
String rootDirId = getRootDirId();
67+
validate(rootDirId == null || rootDirId == "", "No destination folder has been configured. Contact your administrator for assistance.");
6368

6469
if (checkinDocuments.isEmpty()) {
6570
FileList driveIndex = getFoldersInRoot(drive, rootDirId);
@@ -87,6 +92,17 @@ protected void getCheckinDocuments(
8792
}
8893
}
8994

95+
private String getRootDirId() {
96+
String rootDirId;
97+
try {
98+
rootDirId = settingsServices.systemFindByName(SettingOption.DIRECTORY_ID.name()).getValue();
99+
}
100+
catch (NotFoundException e ) {
101+
rootDirId = "";
102+
}
103+
return rootDirId;
104+
}
105+
90106
@Override
91107
protected void downloadSingleFile(String docId, FileOutputStream myWriter) throws IOException {
92108
Drive drive = googleApiAccess.getDrive();
@@ -103,7 +119,7 @@ protected FileInfoDTO uploadSingleFile(CompletedFileUpload file, String director
103119
Drive drive = googleApiAccess.getDrive();
104120
validate(drive == null, "Unable to access Google Drive");
105121

106-
String rootDirId = googleServiceConfiguration.getDirectoryId();
122+
String rootDirId = getRootDirId();
107123
validate(rootDirId == null, "No destination folder has been configured. Contact your administrator for assistance.");
108124

109125
// Check if folder already exists on google drive. If exists, return folderId and name
@@ -153,7 +169,7 @@ public FileInfoDTO uploadDocument(String directoryName, String name, String text
153169
Drive drive = googleApiAccess.getDrive();
154170
validate(drive == null, "Unable to access Google Drive");
155171

156-
String rootDirId = googleServiceConfiguration.getDirectoryId();
172+
String rootDirId = getRootDirId();
157173
validate(rootDirId == null, "No destination folder has been configured. Contact your administrator for assistance.");
158174

159175
// Check if folder already exists on google drive. If exists, return folderId and name

server/src/main/java/com/objectcomputing/checkins/services/pulse/PulseServicesImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void notifyUsers(LocalDate check) {
7878
.with(TemporalAdjusters.firstInMonth(emailDay));
7979

8080
try {
81-
Setting freq = settingsServices.findByName("PULSE_EMAIL_FREQUENCY");
81+
Setting freq = settingsServices.systemFindByName("PULSE_EMAIL_FREQUENCY");
8282
if (frequency.containsKey(freq.getValue())) {
8383
setting = freq.getValue();
8484
} else {

0 commit comments

Comments
 (0)