Skip to content

Commit 041c918

Browse files
committed
feat: enhance GitHub Actions workflow with improved debugging and verification steps for Maven and Docker
1 parent 95b31ac commit 041c918

File tree

1 file changed

+61
-17
lines changed

1 file changed

+61
-17
lines changed

.github/workflows/deploy.yml

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ jobs:
2626
server-username: MAVEN_USERNAME
2727
server-password: MAVEN_PASSWORD
2828

29-
- name: Verify Maven Configuration
29+
- name: Debug Maven Configuration
3030
run: |
31-
echo "Checking Maven setup..."
31+
echo "Verifying Maven configuration..."
3232
echo "JAVA_HOME: $JAVA_HOME"
3333
mvn -version
3434
ls -la ~/.m2 || true
35-
35+
3636
- name: Setup Maven Settings
3737
run: |
3838
mkdir -p ~/.m2
@@ -47,17 +47,53 @@ jobs:
4747
<password>${{ secrets.MAVEN_PASSWORD }}</password>
4848
</server>
4949
</servers>
50+
<mirrors>
51+
<mirror>
52+
<id>central</id>
53+
<name>Maven Central</name>
54+
<url>https://repo1.maven.org/maven2/</url>
55+
<mirrorOf>central</mirrorOf>
56+
</mirror>
57+
</mirrors>
58+
<profiles>
59+
<profile>
60+
<id>default</id>
61+
<repositories>
62+
<repository>
63+
<id>central</id>
64+
<url>https://repo1.maven.org/maven2</url>
65+
<releases>
66+
<enabled>true</enabled>
67+
</releases>
68+
<snapshots>
69+
<enabled>false</enabled>
70+
</snapshots>
71+
</repository>
72+
</repositories>
73+
</profile>
74+
</profiles>
75+
<activeProfiles>
76+
<activeProfile>default</activeProfile>
77+
</activeProfiles>
5078
</settings>' > ~/.m2/settings.xml
5179
5280
- name: Build with Maven
5381
env:
5482
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
5583
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
5684
run: |
57-
mvn -B -s ~/.m2/settings.xml clean install -DskipTests
85+
echo "Starting Maven build..."
86+
mvn -B -X -s ~/.m2/settings.xml clean install -DskipTests || {
87+
echo "Maven build failed. Checking settings..."
88+
ls -la ~/.m2
89+
echo "Current directory contents:"
90+
ls -la
91+
exit 1
92+
}
5893
5994
- name: Verify Build Artifacts
6095
run: |
96+
echo "Checking build artifacts..."
6197
for service in api-gateway eureka-server recommendation-service statistics-service user-tracking-service; do
6298
if [ -f "$service/target/$service-1.0-SNAPSHOT.jar" ]; then
6399
echo "$service build successful"
@@ -70,27 +106,37 @@ jobs:
70106
- name: Set up Docker Buildx
71107
uses: docker/setup-buildx-action@v1
72108

109+
- name: Verify Docker Configuration
110+
run: |
111+
echo "Docker version:"
112+
docker version
113+
echo "Docker info:"
114+
docker info
115+
73116
- name: Log in to Oracle Container Registry
74117
uses: docker/login-action@v1
75118
with:
76119
registry: ${{ secrets.OCI_REGISTRY }}
77120
username: ${{ secrets.OCI_USERNAME }}
78121
password: ${{ secrets.OCI_AUTH_TOKEN }}
79122

80-
- name: Build and Push Docker Images
123+
- name: Build and push Docker images
81124
env:
82125
REGISTRY: ${{ secrets.OCI_REGISTRY }}
83126
NAMESPACE: ${{ secrets.OCI_NAMESPACE }}
84127
run: |
128+
echo "Building and pushing Docker images..."
85129
services=("api-gateway" "eureka-server" "recommendation-service" "statistics-service" "user-tracking-service")
130+
86131
for service in "${services[@]}"; do
87-
echo "Building and pushing $service..."
88-
docker build -t ${REGISTRY}/${NAMESPACE}/$service:latest -f $service/Dockerfile .
89-
docker push ${REGISTRY}/${NAMESPACE}/$service:latest
132+
echo "Building $service..."
133+
docker build -t ${REGISTRY}/${NAMESPACE}/$service:latest -f $service/Dockerfile . || exit 1
134+
docker push ${REGISTRY}/${NAMESPACE}/$service:latest || exit 1
135+
echo "$service successfully built and pushed."
90136
done
91137
92138
- name: Log out from Oracle Container Registry
93-
if: ${{ always() }}
139+
if: always()
94140
run: docker logout ${{ secrets.OCI_REGISTRY }}
95141

96142
deploy:
@@ -117,30 +163,28 @@ jobs:
117163
env:
118164
ORACLE_VM_IP: ${{ secrets.ORACLE_VM_IP }}
119165
run: |
166+
echo "Verifying VM connection..."
120167
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ssh_key.pem
121168
chmod 600 ssh_key.pem
122-
ssh -o StrictHostKeyChecking=no -i ssh_key.pem opc@${ORACLE_VM_IP} echo "VM connection successful" || {
123-
echo "Failed to connect to VM"
124-
exit 1
125-
}
169+
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 -i ssh_key.pem opc@${ORACLE_VM_IP} echo "VM connection successful" || exit 1
126170
127171
- name: Deploy to Oracle VM
128172
env:
129173
ORACLE_VM_IP: ${{ secrets.ORACLE_VM_IP }}
130174
run: |
175+
echo "Starting deployment..."
131176
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ssh_key.pem
132177
chmod 600 ssh_key.pem
133178
ssh -o StrictHostKeyChecking=no -i ssh_key.pem opc@${ORACLE_VM_IP} << 'EOF'
134-
echo "Deploying to VM..."
135179
cd ~/music-analytics/vm-deploy || exit 1
136180
docker login ${REGISTRY} -u ${OCI_USERNAME} -p ${OCI_AUTH_TOKEN} || exit 1
137-
docker-compose pull || { docker logout ${REGISTRY}; exit 1; }
138-
docker-compose up -d || { docker logout ${REGISTRY}; exit 1; }
181+
docker-compose pull || exit 1
182+
docker-compose up -d || exit 1
139183
docker logout ${REGISTRY}
140184
echo "Deployment completed successfully"
141185
EOF
142186
rm -f ssh_key.pem
143187
144188
- name: Log out from Oracle Container Registry
145-
if: ${{ always() }}
189+
if: always()
146190
run: docker logout ${{ secrets.OCI_REGISTRY }}

0 commit comments

Comments
 (0)