13
13
permissions :
14
14
contents : read
15
15
packages : write
16
+ outputs :
17
+ image_digest : ${{ steps.image_digest.outputs.IMAGE_DIGEST }}
16
18
17
19
steps :
18
20
- name : Checkout repository
@@ -66,10 +68,67 @@ jobs:
66
68
67
69
- name : Build and push Docker image
68
70
uses : docker/build-push-action@v4
71
+ id : docker_build
69
72
with :
70
73
context : ./install/docker/cws-image
71
74
push : ${{ github.event_name != 'pull_request' }}
72
75
tags : ${{ steps.meta.outputs.tags }}
73
76
labels : ${{ steps.meta.outputs.labels }}
74
77
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