Skip to content

Commit c95f2a6

Browse files
authored
Merge pull request #2115 from OWASP/copilot/fix-2114
Auto-create master Docker containers and publish to GitHub Container Registry
2 parents f384c1a + 1ec40af commit c95f2a6

File tree

2 files changed

+138
-1
lines changed

2 files changed

+138
-1
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Build and Publish Master Container
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
build-and-publish:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up JDK 23
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: "23"
24+
distribution: "oracle"
25+
cache: "maven"
26+
27+
- name: Extract version from pom.xml
28+
id: extract-version
29+
run: |
30+
echo "Extracting version from pom.xml..."
31+
chmod +x ./mvnw
32+
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
33+
DOCKER_VERSION=${VERSION%-SNAPSHOT}
34+
echo "version=$VERSION" >> $GITHUB_OUTPUT
35+
echo "docker_version=$DOCKER_VERSION" >> $GITHUB_OUTPUT
36+
echo "Detected version: $VERSION"
37+
echo "Docker version: $DOCKER_VERSION"
38+
39+
- name: Build application
40+
run: ./mvnw --no-transfer-progress clean package -DskipTests
41+
42+
- name: Verify JAR file was created
43+
run: |
44+
echo "Checking target directory..."
45+
ls -la target/
46+
echo "Looking for JAR files..."
47+
find target/ -name "*.jar" -type f
48+
echo "Verifying specific JAR exists..."
49+
JAR_FILE="target/wrongsecrets-${{ steps.extract-version.outputs.version }}.jar"
50+
if [ -f "$JAR_FILE" ]; then
51+
echo "✅ JAR file found: $JAR_FILE"
52+
ls -la "$JAR_FILE"
53+
else
54+
echo "❌ Expected JAR file not found: $JAR_FILE"
55+
echo "Available JAR files:"
56+
find target/ -name "*.jar" -type f || echo "No JAR files found"
57+
exit 1
58+
fi
59+
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@v3
62+
63+
- name: Log in to GitHub Container Registry
64+
uses: docker/login-action@v3
65+
with:
66+
registry: ghcr.io
67+
username: ${{ github.actor }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Extract metadata
71+
id: meta
72+
uses: docker/metadata-action@v5
73+
with:
74+
images: ghcr.io/${{ github.repository }}/wrongsecrets-master
75+
tags: |
76+
type=ref,event=branch
77+
type=raw,value=latest-master
78+
type=sha,prefix={{branch}}-
79+
80+
- name: Build and push Docker image
81+
id: build
82+
uses: docker/build-push-action@v5
83+
with:
84+
context: .
85+
push: true
86+
tags: ${{ steps.meta.outputs.tags }}
87+
labels: ${{ steps.meta.outputs.labels }}
88+
build-args: |
89+
argBasedVersion=${{ steps.extract-version.outputs.docker_version }}
90+
cache-from: type=gha
91+
cache-to: type=gha,mode=max
92+
93+
- name: Verify Docker image was built
94+
run: |
95+
echo "Verifying Docker image was built successfully..."
96+
echo "Image tags: ${{ steps.meta.outputs.tags }}"
97+
echo "Image digest: ${{ steps.build.outputs.digest }}"
98+
99+
- name: Create Release Summary
100+
run: |
101+
echo "## 🚀 Master Container Published" >> $GITHUB_STEP_SUMMARY
102+
echo "" >> $GITHUB_STEP_SUMMARY
103+
echo "**📦 Container Images Published:**" >> $GITHUB_STEP_SUMMARY
104+
echo "" >> $GITHUB_STEP_SUMMARY
105+
106+
# Convert multi-line tags to individual entries
107+
TAGS="${{ steps.meta.outputs.tags }}"
108+
echo "$TAGS" | while read -r tag; do
109+
if [ ! -z "$tag" ]; then
110+
echo "- \`$tag\`" >> $GITHUB_STEP_SUMMARY
111+
fi
112+
done
113+
114+
echo "" >> $GITHUB_STEP_SUMMARY
115+
echo "**🐳 Try the bleeding-edge version:**" >> $GITHUB_STEP_SUMMARY
116+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
117+
echo "docker pull ghcr.io/${{ github.repository }}/wrongsecrets-master:latest-master" >> $GITHUB_STEP_SUMMARY
118+
echo "docker run -p 8080:8080 ghcr.io/${{ github.repository }}/wrongsecrets-master:latest-master" >> $GITHUB_STEP_SUMMARY
119+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
120+
echo "" >> $GITHUB_STEP_SUMMARY
121+
echo "Then visit: http://localhost:8080" >> $GITHUB_STEP_SUMMARY

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ Want to play the other challenges? Read the instructions on how to set them up b
3232
docker run -p 8080:8080 jeroenwillemsen/wrongsecrets:latest-no-vault
3333
```
3434
Then open [http://localhost:8080](http://localhost:8080)
35-
3. **Advanced Setup**: For cloud challenges and Kubernetes exercises, see the detailed instructions below
35+
3. **Want to see what's ahead?** Try our bleeding-edge master container with the latest features:
36+
```bash
37+
docker run -p 8080:8080 ghcr.io/owasp/wrongsecrets/wrongsecrets-master:latest-master
38+
```
39+
⚠️ *Note: This is a development version and may be unstable*
40+
4. **Advanced Setup**: For cloud challenges and Kubernetes exercises, see the detailed instructions below
3641

3742
**What you'll learn:**
3843
- Common secrets management mistakes
@@ -143,6 +148,17 @@ You can install it by doing:
143148
```bash
144149
docker run -p 8080:8080 jeroenwillemsen/wrongsecrets:latest-no-vault
145150
```
151+
152+
**🚀 Want to try the bleeding-edge version?**
153+
154+
If you want to see what's coming in the next release, you can use our automatically-built master container:
155+
156+
```bash
157+
docker run -p 8080:8080 ghcr.io/owasp/wrongsecrets/wrongsecrets-master:latest-master
158+
```
159+
160+
⚠️ **Warning**: This is a development version built from the latest master branch and may contain experimental features or instabilities.
161+
146162
Now you can try to find the secrets by means of solving the challenge offered at the links below
147163
<details>
148164
<summary>all the links for docker challenges (click triangle to open the block).

0 commit comments

Comments
 (0)