Skip to content

Commit 3e209b1

Browse files
committed
Refactor deploy workflow with testing and Docker build improvements
1 parent edf40d5 commit 3e209b1

File tree

1 file changed

+53
-18
lines changed

1 file changed

+53
-18
lines changed

.github/workflows/deploy.yml

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,79 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install Python deps
18+
run: |
19+
sudo apt-get update
20+
sudo apt-get install -y python3-pip
21+
pip3 install --upgrade pip
22+
pip3 install --no-cache-dir -r requirements.txt
23+
- name: Run Python tests
24+
run: |
25+
# Run Python tests
26+
27+
- name: Install Maven
28+
run: |
29+
apt-get update && \
30+
apt-get install -y --no-install-recommends maven && \
31+
apt-get clean && \
32+
rm -rf /var/lib/apt/lists/*
33+
- name: Run Maven tests
34+
run: |
35+
# Run Maven tests
36+
1137
build-and-push:
38+
needs: test
1239
runs-on: ubuntu-latest
1340
steps:
1441
- name: Checkout
15-
uses: actions/checkout@v3
42+
uses: actions/checkout@v4
1643

17-
- name: Log in to Docker Registry
44+
- name: Verify DockerHub credentials
45+
run: |
46+
if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_PASSWORD }}" ]; then
47+
echo "Missing DockerHub credentials"
48+
exit 1
49+
fi
50+
51+
- name: Log in to Docker Hub
1852
if: github.ref == 'refs/heads/main'
19-
uses: docker/login-action@v2
53+
uses: docker/login-action@v3
2054
with:
2155
registry: docker.io
2256
username: ${{ secrets.DOCKERHUB_USERNAME }}
2357
password: ${{ secrets.DOCKERHUB_PASSWORD }}
2458

25-
- name: Build diffy-bot-client Image
26-
run: |
27-
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/diffy-bot-client:latest -f solver-bot/Dockerfile .
28-
29-
- name: Build diffy-bot-server Image
30-
run: |
31-
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/diffy-bot-server:latest -f solver-common/Dockerfile .
32-
33-
- name: Push diffy-bot-client Image
59+
- name: Build and push diffy-bot-client
3460
if: github.ref == 'refs/heads/main'
35-
run: |
36-
docker push ${{ secrets.DOCKERHUB_USERNAME }}/diffy-bot-client:latest
61+
uses: docker/build-push-action@v4
62+
with:
63+
context: .
64+
file: solver-bot/Dockerfile
65+
push: true
66+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/diffy-bot-client:latest
3767

38-
- name: Push diffy-bot-server Image
68+
- name: Build and push diffy-bot-server
3969
if: github.ref == 'refs/heads/main'
40-
run: |
41-
docker push ${{ secrets.DOCKERHUB_USERNAME }}/diffy-bot-server:latest
70+
uses: docker/build-push-action@v4
71+
with:
72+
context: .
73+
file: solver-common/Dockerfile
74+
push: true
75+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/diffy-bot-server:latest
4276

4377
deploy:
4478
needs: build-and-push
4579
runs-on: ubuntu-latest
4680
steps:
4781
- name: Checkout
48-
uses: actions/checkout@v3
82+
uses: actions/checkout@v4
83+
4984
- name: Create .env file from secrets
5085
run: |
5186
echo "CLIENT_API_KEY=${{ secrets.CLIENT_API_KEY }}" >> .env

0 commit comments

Comments
 (0)