Skip to content

Commit af09bd6

Browse files
authored
Merge pull request #194 from contentstack/staging
back merge
2 parents 7eb50ed + 9569279 commit af09bd6

File tree

5 files changed

+72
-24
lines changed

5 files changed

+72
-24
lines changed

.github/workflows/check-branch.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Comment PR
11-
if: github.base_ref == 'master' && github.head_ref != 'next'
11+
if: github.base_ref == 'master' && github.head_ref != 'staging'
1212
uses: thollander/actions-comment-pull-request@v2
1313
with:
1414
message: |
15-
We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the next branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.
15+
We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the staging branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.
1616
- name: Check branch
17-
if: github.base_ref == 'master' && github.head_ref != 'next'
17+
if: github.base_ref == 'master' && github.head_ref != 'staging'
1818
run: |
19-
echo "ERROR: We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the next branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch."
19+
echo "ERROR: We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the staging branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch."
2020
exit 1

.github/workflows/secrets-scan.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Secrets Scan
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
jobs:
6+
security-secrets:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
fetch-depth: '2'
12+
ref: '${{ github.event.pull_request.head.ref }}'
13+
- run: |
14+
git reset --soft HEAD~1
15+
- name: Install Talisman
16+
run: |
17+
# Download Talisman
18+
wget https://github.com/thoughtworks/talisman/releases/download/v1.37.0/talisman_linux_amd64 -O talisman
19+
20+
# Checksum verification
21+
checksum=$(sha256sum ./talisman | awk '{print $1}')
22+
if [ "$checksum" != "8e0ae8bb7b160bf10c4fa1448beb04a32a35e63505b3dddff74a092bccaaa7e4" ]; then exit 1; fi
23+
24+
# Make it executable
25+
chmod +x talisman
26+
- name: Run talisman
27+
run: |
28+
# Run Talisman with the pre-commit hook
29+
./talisman --githook pre-commit

.talismanrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
threshold: medium
2+
fileignoreconfig:
3+
- filename: .github/workflows/secrets-scan.yml
4+
checksum: d79ec3f3288964f7d117b9ad319a54c0ebc152e35f69be8fde95522034fdfb2a
5+
version: "1.0"

pom.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,24 @@
201201
<artifactId>slf4j-simple</artifactId>
202202
<version>1.7.36</version>
203203
</dependency>
204+
<!-- https://mvnrepository.com/artifact/io.github.cdimascio/java-dotenv -->
205+
<dependency>
206+
<groupId>io.github.cdimascio</groupId>
207+
<artifactId>java-dotenv</artifactId>
208+
<version>5.2.2</version>
209+
</dependency>
204210

205211
</dependencies>
206-
212+
213+
<dependencyManagement>
214+
<dependencies>
215+
<dependency>
216+
<groupId>org.jetbrains.kotlin</groupId>
217+
<artifactId>kotlin-stdlib</artifactId>
218+
<version>2.1.0</version>
219+
</dependency>
220+
</dependencies>
221+
</dependencyManagement>
207222
<build>
208223

209224

src/test/java/com/contentstack/sdk/Credentials.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.contentstack.sdk;
22

3-
import java.io.FileInputStream;
4-
import java.io.IOException;
53
import java.rmi.AccessException;
64
import java.util.Arrays;
7-
import java.util.Properties;
5+
import io.github.cdimascio.dotenv.Dotenv;
86

97
public class Credentials {
10-
private static final Properties properties = new Properties();
8+
9+
static Dotenv env = getEnv();
1110

1211
private static String envChecker() {
1312
String githubActions = System.getenv("GITHUB_ACTIONS");
@@ -18,24 +17,25 @@ private static String envChecker() {
1817
}
1918
}
2019

21-
static {
22-
try (FileInputStream inputStream = new FileInputStream("src/test/resources/test-config.properties")) {
23-
properties.load(inputStream);
24-
} catch (IOException e) {
25-
System.err.println("Error loading properties file: " + e.getMessage());
26-
}
27-
}
20+
public static Dotenv getEnv() {
21+
env = Dotenv.configure()
22+
.directory("src/test/resources")
23+
.filename("env") // instead of '.env', use 'env'
24+
.load();
25+
26+
return Dotenv.load();
27+
}
2828

29-
public static final String HOST = properties.getProperty("HOST", "cdn.contentstack.io");
30-
public static final String API_KEY = properties.getProperty("API_KEY", "");
31-
public static final String DELIVERY_TOKEN = properties.getProperty("DELIVERY_TOKEN", "");
32-
public static final String ENVIRONMENT = properties.getProperty("ENVIRONMENT", "env1");
33-
public static final String CONTENT_TYPE = properties.getProperty("contentType", "product");
34-
public static final String ENTRY_UID = properties.getProperty("assetUid", "");
35-
public static final String VARIANT_UID = properties.getProperty("variantUid", "");
29+
public static final String HOST = env.get("HOST", "cdn.contentstack.io");
30+
public static final String API_KEY = env.get("API_KEY", "");
31+
public static final String DELIVERY_TOKEN = env.get("DELIVERY_TOKEN", "");
32+
public static final String ENVIRONMENT = env.get("ENVIRONMENT", "env1");
33+
public static final String CONTENT_TYPE = env.get("contentType", "product");
34+
public static final String ENTRY_UID = env.get("assetUid", "");
35+
public static final String VARIANT_UID = env.get("variantUid", "");
3636
public final static String[] VARIANTS_UID;
3737
static {
38-
String variantsUidString = properties.getProperty("variantsUid");
38+
String variantsUidString = env.get("variantsUid");
3939

4040
if (variantsUidString != null && !variantsUidString.trim().isEmpty()) {
4141
VARIANTS_UID = Arrays.stream(variantsUidString.split(","))

0 commit comments

Comments
 (0)