Skip to content

Commit dba46a2

Browse files
ci(check-deployed-package): add workflow and Docker auth script
1 parent 620991c commit dba46a2

File tree

7 files changed

+102
-19
lines changed

7 files changed

+102
-19
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Make run script executable
30+
run: chmod +x check-deployed-package/run.sh
31+
32+
- name: Run LogDash demo
33+
env:
34+
LOGDASH_API_KEY: ${{ secrets.LOGDASH_API_KEY }}
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
GITHUB_ACTOR: ${{ github.actor }}
37+
run: ./check-deployed-package/run.sh

check-deployed-package/Dockerfile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
FROM eclipse-temurin:17-jdk
22

3+
ARG GITHUB_TOKEN
4+
ARG GITHUB_ACTOR
5+
36
WORKDIR /app
47

58
# Install Maven
69
RUN apt-get update && apt-get install -y maven && rm -rf /var/lib/apt/lists/*
710

8-
# Copy pom.xml and source files
11+
# Copy Maven settings
12+
COPY check-deployed-package/settings.xml /root/.m2/settings.xml
13+
14+
# Copy project files
915
COPY check-deployed-package/pom.xml .
1016
COPY check-deployed-package/Check.java src/main/java/com/logdash/check/Check.java
1117

12-
# Download dependencies and compile
13-
RUN mvn compile
18+
# Set environment variables for Maven settings.xml
19+
ENV GITHUB_TOKEN=${GITHUB_TOKEN}
20+
ENV GITHUB_ACTOR=${GITHUB_ACTOR}
21+
22+
# Copy and make executable startup script
23+
COPY check-deployed-package/start.sh /app/start.sh
24+
RUN chmod +x /app/start.sh
1425

15-
CMD ["mvn", "exec:java"]
26+
CMD ["/app/start.sh"]

check-deployed-package/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Use command below to test if the published SDK works:
55
```
66
LOGDASH_API_KEY=<your-api-key> ./check-deployed-package/run.sh
77
```
8+

check-deployed-package/pom.xml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?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">
63
<modelVersion>4.0.0</modelVersion>
74
<groupId>com.logdash</groupId>
85
<artifactId>check</artifactId>
@@ -12,22 +9,23 @@
129
<maven.compiler.target>17</maven.compiler.target>
1310
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1411
</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-
12+
2413
<dependencies>
2514
<dependency>
2615
<groupId>io.logdash</groupId>
2716
<artifactId>logdash</artifactId>
2817
<version>0.1.0</version>
2918
</dependency>
3019
</dependencies>
20+
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+
</repository>
27+
</repositories>
28+
3129
<build>
3230
<plugins>
3331
<plugin>
@@ -49,4 +47,4 @@
4947
</plugin>
5048
</plugins>
5149
</build>
52-
</project>
50+
</project>

check-deployed-package/run.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ METRICS_SEED=$(awk 'BEGIN{srand(); print int(rand()*1000000)+1}')
1010
echo "Generated metrics seed: $METRICS_SEED"
1111

1212
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 .
1418

1519
echo
1620
echo "Running LogDash Java demo..."

check-deployed-package/settings.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
<servers>
7+
<server>
8+
<id>github</id>
9+
<username>${env.GITHUB_ACTOR}</username>
10+
<password>${env.GITHUB_TOKEN}</password>
11+
</server>
12+
</servers>
13+
14+
<profiles>
15+
<profile>
16+
<id>github-auth</id>
17+
<activation>
18+
<property>
19+
<name>env.GITHUB_TOKEN</name>
20+
</property>
21+
</activation>
22+
</profile>
23+
</profiles>
24+
</settings>

check-deployed-package/start.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Compiling with Maven..."
5+
mvn compile -B --no-transfer-progress
6+
7+
echo "Running application..."
8+
mvn exec:java

0 commit comments

Comments
 (0)