File tree Expand file tree Collapse file tree 7 files changed +135
-25
lines changed Expand file tree Collapse file tree 7 files changed +135
-25
lines changed Original file line number Diff line number Diff line change
1
+ name : Check deployed package
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ push :
6
+ branches :
7
+ - main
8
+ - ' feat/package-auto-check-script'
9
+ pull_request :
10
+ branches :
11
+ - main
12
+ - ' feat/package-auto-check-script'
13
+
14
+ jobs :
15
+ check-deployed-package :
16
+ name : Check deployed package
17
+ runs-on : ubuntu-latest
18
+ permissions :
19
+ contents : read
20
+ packages : read
21
+
22
+ steps :
23
+ - name : Checkout repository
24
+ uses : actions/checkout@v4
25
+
26
+ - name : Make run script executable
27
+ run : chmod +x check-deployed-package/run.sh
28
+
29
+ - name : Verify environment variables
30
+ run : |
31
+ echo "GITHUB_ACTOR: ${{ github.actor }}"
32
+ echo "Has GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN != '' }}"
33
+ echo "Has LOGDASH_API_KEY: ${{ secrets.LOGDASH_API_KEY != '' }}"
34
+
35
+ - name : Run LogDash demo
36
+ env :
37
+ LOGDASH_API_KEY : ${{ secrets.LOGDASH_API_KEY }}
38
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
39
+ GITHUB_ACTOR : ${{ github.actor }}
40
+ run : ./check-deployed-package/run.sh
Original file line number Diff line number Diff line change @@ -38,13 +38,6 @@ public static void main(String[] args) {
38
38
int seedValue = Integer .parseInt (metricsSeed );
39
39
metrics .set ("users" , seedValue );
40
40
metrics .mutate ("users" , 1 );
41
-
42
- // Wait to ensure data is sent
43
- try {
44
- Thread .sleep (2000 );
45
- } catch (InterruptedException e ) {
46
- Thread .currentThread ().interrupt ();
47
- }
48
41
}
49
42
}
50
43
Original file line number Diff line number Diff line change 1
1
FROM eclipse-temurin:17-jdk
2
2
3
+ ARG GITHUB_TOKEN
4
+ ARG GITHUB_ACTOR
5
+
3
6
WORKDIR /app
4
7
5
8
# Install Maven
6
9
RUN apt-get update && apt-get install -y maven && rm -rf /var/lib/apt/lists/*
7
10
8
- # Copy pom.xml and source files
11
+ # Set environment variables for Maven authentication
12
+ ENV GITHUB_TOKEN=${GITHUB_TOKEN}
13
+ ENV GITHUB_ACTOR=${GITHUB_ACTOR}
14
+
15
+ # Copy Maven settings with GitHub authentication
16
+ COPY check-deployed-package/settings.xml /root/.m2/settings.xml
17
+
18
+ # Copy project files
9
19
COPY check-deployed-package/pom.xml .
10
20
COPY check-deployed-package/Check.java src/main/java/com/logdash/check/Check.java
11
21
12
22
# Download dependencies and compile
13
- RUN mvn compile
23
+ RUN mvn dependency:resolve compile -B --no-transfer-progress \
24
+ -Dgithub.username=${GITHUB_ACTOR} \
25
+ -Dgithub.password=${GITHUB_TOKEN}
26
+
27
+ # Add environment variable validation
28
+ ENV LOGDASH_API_KEY=""
29
+ ENV LOGS_SEED=""
30
+ ENV METRICS_SEED=""
14
31
15
- CMD ["mvn" , "exec:java" ]
32
+ # Run the application with environment validation
33
+ CMD if [ -z "$LOGDASH_API_KEY" ]; then \
34
+ echo "Error: LOGDASH_API_KEY environment variable is required" ; \
35
+ exit 1; \
36
+ fi; \
37
+ mvn exec:java -B --no-transfer-progress
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ Use command below to test if the published SDK works:
5
5
```
6
6
LOGDASH_API_KEY=<your-api-key> ./check-deployed-package/run.sh
7
7
```
8
+
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
- <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
- xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0
5
- https://maven.apache.org/xsd/maven-4.0.0.xsd" >
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" >
6
3
<modelVersion >4.0.0</modelVersion >
7
4
<groupId >com.logdash</groupId >
8
5
<artifactId >check</artifactId >
9
6
<version >1.0.0</version >
7
+
10
8
<properties >
11
9
<maven .compiler.source>17</maven .compiler.source>
12
10
<maven .compiler.target>17</maven .compiler.target>
13
11
<project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
14
12
</properties >
15
-
16
- <repositories >
17
- <repository >
18
- <id >github</id >
19
- <name >GitHub Packages</name >
20
- <url >https://maven.pkg.github.com/logdash-io/java-sdk</url >
21
- </repository >
22
- </repositories >
23
-
13
+
24
14
<dependencies >
25
15
<dependency >
26
16
<groupId >io.logdash</groupId >
27
17
<artifactId >logdash</artifactId >
28
18
<version >0.1.0</version >
29
19
</dependency >
30
20
</dependencies >
21
+
22
+ <repositories >
23
+ <repository >
24
+ <id >github</id >
25
+ <name >GitHub Packages</name >
26
+ <url >https://maven.pkg.github.com/logdash-io/java-sdk</url >
27
+ <releases >
28
+ <enabled >true</enabled >
29
+ </releases >
30
+ <snapshots >
31
+ <enabled >true</enabled >
32
+ </snapshots >
33
+ </repository >
34
+ </repositories >
35
+
31
36
<build >
32
37
<plugins >
33
38
<plugin >
45
50
<version >3.1.0</version >
46
51
<configuration >
47
52
<mainClass >com.logdash.check.Check</mainClass >
53
+ <options >
54
+ <option >-Dfile.encoding=UTF-8</option >
55
+ </options >
48
56
</configuration >
49
57
</plugin >
50
58
</plugins >
51
59
</build >
52
- </project >
60
+ </project >
Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ METRICS_SEED=$(awk 'BEGIN{srand(); print int(rand()*1000000)+1}')
10
10
echo " Generated metrics seed: $METRICS_SEED "
11
11
12
12
echo " Building LogDash Java demo Docker image (using published package)..."
13
- docker build --no-cache -t logdash-java-demo -f check-deployed-package/Dockerfile .
13
+ docker build --no-cache \
14
+ --build-arg GITHUB_TOKEN=" ${GITHUB_TOKEN} " \
15
+ --build-arg GITHUB_ACTOR=" ${GITHUB_ACTOR} " \
16
+ -t logdash-java-demo \
17
+ -f check-deployed-package/Dockerfile .
14
18
15
19
echo
16
20
echo " Running LogDash Java demo..."
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <settings xmlns =" http://maven.apache.org/SETTINGS/1.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/SETTINGS/1.0.0
5
+ https://maven.apache.org/xsd/settings-1.0.0.xsd" >
6
+
7
+ <servers >
8
+ <server >
9
+ <id >github</id >
10
+ <username >${env.GITHUB_ACTOR}</username >
11
+ <password >${env.GITHUB_TOKEN}</password >
12
+ </server >
13
+ </servers >
14
+
15
+ <profiles >
16
+ <profile >
17
+ <id >github-auth</id >
18
+ <activation >
19
+ <activeByDefault >true</activeByDefault >
20
+ </activation >
21
+ <repositories >
22
+ <repository >
23
+ <id >github</id >
24
+ <name >GitHub Packages</name >
25
+ <url >https://maven.pkg.github.com/logdash-io/java-sdk</url >
26
+ <releases >
27
+ <enabled >true</enabled >
28
+ <updatePolicy >daily</updatePolicy >
29
+ </releases >
30
+ <snapshots >
31
+ <enabled >true</enabled >
32
+ <updatePolicy >always</updatePolicy >
33
+ </snapshots >
34
+ </repository >
35
+ </repositories >
36
+ </profile >
37
+ </profiles >
38
+
39
+ <activeProfiles >
40
+ <activeProfile >github-auth</activeProfile >
41
+ </activeProfiles >
42
+ </settings >
You can’t perform that action at this time.
0 commit comments