|
8 | 8 | workflow_dispatch: |
9 | 9 |
|
10 | 10 | 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 | +
|
11 | 37 | build-and-push: |
| 38 | + needs: test |
12 | 39 | runs-on: ubuntu-latest |
13 | 40 | steps: |
14 | 41 | - name: Checkout |
15 | | - uses: actions/checkout@v3 |
| 42 | + uses: actions/checkout@v4 |
16 | 43 |
|
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 |
18 | 52 | if: github.ref == 'refs/heads/main' |
19 | | - uses: docker/login-action@v2 |
| 53 | + uses: docker/login-action@v3 |
20 | 54 | with: |
21 | 55 | registry: docker.io |
22 | 56 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
23 | 57 | password: ${{ secrets.DOCKERHUB_PASSWORD }} |
24 | 58 |
|
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 |
34 | 60 | 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 |
37 | 67 |
|
38 | | - - name: Push diffy-bot-server Image |
| 68 | + - name: Build and push diffy-bot-server |
39 | 69 | 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 |
42 | 76 |
|
43 | 77 | deploy: |
44 | 78 | needs: build-and-push |
45 | 79 | runs-on: ubuntu-latest |
46 | 80 | steps: |
47 | 81 | - name: Checkout |
48 | | - uses: actions/checkout@v3 |
| 82 | + uses: actions/checkout@v4 |
| 83 | + |
49 | 84 | - name: Create .env file from secrets |
50 | 85 | run: | |
51 | 86 | echo "CLIENT_API_KEY=${{ secrets.CLIENT_API_KEY }}" >> .env |
|
0 commit comments