source: .github/workflows/ci-cd.yml@ a8fe58e

Last change on this file since a8fe58e was a8fe58e, checked in by Andrej <asumanovski@…>, 2 weeks ago

Simplify pipeline to CI only — build and push to DockerHub, no deployment

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[a8fe58e]1name: CI
[c0086c0]2
3on:
4 push:
[a8fe58e]5 branches: [master, dev]
[c0086c0]6 pull_request:
7 branches: [master]
8
9env:
10 BACKEND_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/trekr-backend
11 FRONTEND_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/trekr-frontend
12
13jobs:
14 build:
15 name: Build
16 runs-on: ubuntu-latest
17 steps:
18 - uses: actions/checkout@v4
19
20 - name: Set up Docker Buildx
21 uses: docker/setup-buildx-action@v3
22
[a8fe58e]23 - name: Build backend image
[c0086c0]24 uses: docker/build-push-action@v5
25 with:
26 context: ./backend
27 push: false
28 cache-from: type=gha,scope=backend
29 cache-to: type=gha,scope=backend,mode=max
30
[a8fe58e]31 - name: Build frontend image
[c0086c0]32 uses: docker/build-push-action@v5
33 with:
34 context: ./frontend
35 push: false
36 cache-from: type=gha,scope=frontend
37 cache-to: type=gha,scope=frontend,mode=max
38
39 push:
40 name: Push to DockerHub
41 runs-on: ubuntu-latest
42 needs: build
43 if: github.ref == 'refs/heads/master' && github.event_name == 'push'
44 steps:
45 - uses: actions/checkout@v4
46
47 - name: Set up Docker Buildx
48 uses: docker/setup-buildx-action@v3
49
50 - name: Log in to DockerHub
51 uses: docker/login-action@v3
52 with:
53 username: ${{ secrets.DOCKERHUB_USERNAME }}
54 password: ${{ secrets.DOCKERHUB_TOKEN }}
55
56 - name: Build and push backend
57 uses: docker/build-push-action@v5
58 with:
59 context: ./backend
60 push: true
61 tags: |
62 ${{ env.BACKEND_IMAGE }}:latest
63 ${{ env.BACKEND_IMAGE }}:${{ github.sha }}
64 cache-from: type=gha,scope=backend
65 cache-to: type=gha,scope=backend,mode=max
66
67 - name: Build and push frontend
68 uses: docker/build-push-action@v5
69 with:
70 context: ./frontend
71 push: true
72 tags: |
73 ${{ env.FRONTEND_IMAGE }}:latest
74 ${{ env.FRONTEND_IMAGE }}:${{ github.sha }}
75 cache-from: type=gha,scope=frontend
76 cache-to: type=gha,scope=frontend,mode=max
Note: See TracBrowser for help on using the repository browser.