Skip to content

Commit bbdd84a

Browse files
committed
wip2
1 parent dce1941 commit bbdd84a

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

.github/workflows/docker-build.yml

+60-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
permissions:
1414
contents: read
1515
packages: write
16+
outputs:
17+
image_digest: ${{ steps.image_digest.outputs.IMAGE_DIGEST }}
1618

1719
steps:
1820
- name: Checkout repository
@@ -66,10 +68,67 @@ jobs:
6668
6769
- name: Build and push Docker image
6870
uses: docker/build-push-action@v4
71+
id: docker_build
6972
with:
7073
context: ./install/docker/cws-image
7174
push: ${{ github.event_name != 'pull_request' }}
7275
tags: ${{ steps.meta.outputs.tags }}
7376
labels: ${{ steps.meta.outputs.labels }}
7477
cache-from: type=gha
75-
cache-to: type=gha,mode=max
78+
cache-to: type=gha,mode=max
79+
80+
- name: Get image digest
81+
id: image_digest
82+
run: echo "IMAGE_DIGEST=${{ steps.meta.outputs.tags }}" >> $GITHUB_OUTPUT
83+
84+
test:
85+
needs: build
86+
runs-on: ubuntu-latest
87+
if: github.event_name != 'pull_request'
88+
89+
steps:
90+
- name: Checkout repository
91+
uses: actions/checkout@v3
92+
93+
- name: Set up test environment
94+
run: |
95+
mkdir -p test-output
96+
97+
- name: Pull Docker image
98+
run: |
99+
# Extract the first tag from the tags list
100+
IMAGE_TAG=$(echo "${{ needs.build.outputs.image_digest }}" | tr ' ' '\n' | head -n 1)
101+
echo "Using image: ${IMAGE_TAG}"
102+
docker pull ${IMAGE_TAG}
103+
104+
- name: Run tests in container
105+
run: |
106+
# Extract the first tag from the tags list
107+
IMAGE_TAG=$(echo "${{ needs.build.outputs.image_digest }}" | tr ' ' '\n' | head -n 1)
108+
109+
# Run the container with test environment
110+
docker run --name cws-test -d \
111+
-e DB_HOST=mock-db \
112+
-e DB_USER=mockuser \
113+
-e DB_PW=mockpw \
114+
-e ES_PROTOCOL=http \
115+
-e ES_HOST=mock-es \
116+
-e ES_PORT=9200 \
117+
${IMAGE_TAG}
118+
119+
# Check if container is running
120+
docker ps
121+
122+
# Run some basic verification tests
123+
echo "Checking container logs"
124+
docker logs cws-test
125+
126+
# Verify the Java version in the container
127+
docker exec cws-test java -version
128+
129+
# More test commands can be added here
130+
131+
- name: Clean up
132+
run: |
133+
docker stop cws-test || true
134+
docker rm cws-test || true

0 commit comments

Comments
 (0)