|
1 | 1 | name: Build and Publish Docker Images |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch: # Allows manual triggering from GitHub UI |
5 | | - inputs: |
6 | | - api_image_tag: |
7 | | - description: "Tag for the API image" |
8 | | - default: "latest" |
9 | | - required: false |
10 | | - frontend_image_tag: |
11 | | - description: "Tag for the Frontend image" |
12 | | - default: "latest" |
13 | | - required: false |
| 4 | + workflow_dispatch: |
14 | 5 |
|
15 | 6 | jobs: |
16 | | - build_and_push_images: |
| 7 | + publish_images: |
17 | 8 | runs-on: ubuntu-latest |
18 | | - |
19 | 9 | steps: |
20 | | - # Step 1: Checkout repository |
21 | | - - name: Checkout Repository |
| 10 | + # Step 1: Checkout the repository |
| 11 | + - name: Checkout repository |
22 | 12 | uses: actions/checkout@v4 |
23 | | - |
| 13 | + |
24 | 14 | # Step 2: Log in to Docker Hub |
25 | 15 | - name: Log in to Docker Hub |
26 | | - uses: docker/login-action@v2 |
27 | | - with: |
28 | | - username: echelonkay |
29 | | - password: ${{ secrets.DOCKER_HUB_TOKEN }} |
| 16 | + run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "echelonkay" --password-stdin |
30 | 17 |
|
31 | | - # Step 3: Build API Docker Image |
32 | | - - name: Build API Docker Image |
33 | | - run: | |
34 | | - docker build ./api/ \ |
35 | | - -t echelonkay/devops-qr-code-api:${{ github.event.inputs.api_image_tag }} \ |
36 | | - -t echelonkay/devops-qr-code-api:latest \ |
37 | | - --no-cache |
| 18 | + # Step 3: Build API Docker image |
| 19 | + - name: Build API Docker image |
| 20 | + run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest --no-cache |
38 | 21 |
|
39 | | - # Step 4: Push API Docker Image |
40 | | - - name: Push API Docker Image |
41 | | - run: | |
42 | | - docker push echelonkay/devops-qr-code-api:${{ github.event.inputs.api_image_tag }} |
43 | | - docker push echelonkay/devops-qr-code-api:latest |
| 22 | + # Step 4: Build Frontend Docker image |
| 23 | + - name: Build Frontend Docker image |
| 24 | + run: docker build ./front-end-nextjs/ -t echelonkay/devops-qr-code-frontend:latest --no-cache |
44 | 25 |
|
45 | | - # Step 5: Build Frontend Docker Image |
46 | | - - name: Build Frontend Docker Image |
47 | | - run: | |
48 | | - docker build ./front-end-nextjs/ \ |
49 | | - -t echelonkay/devops-qr-code-frontend:${{ github.event.inputs.frontend_image_tag }} \ |
50 | | - -t echelonkay/devops-qr-code-frontend:latest \ |
51 | | - --no-cache |
| 26 | + # Step 5: Push API Docker image to Docker Hub |
| 27 | + - name: Push API Docker image |
| 28 | + run: docker push echelonkay/devops-qr-code-api:latest |
52 | 29 |
|
53 | | - # Step 6: Push Frontend Docker Image |
54 | | - - name: Push Frontend Docker Image |
55 | | - run: | |
56 | | - docker push echelonkay/devops-qr-code-frontend:${{ github.event.inputs.frontend_image_tag }} |
57 | | - docker push echelonkay/devops-qr-code-frontend:latest |
| 30 | + # Step 6: Push Frontend Docker image to Docker Hub |
| 31 | + - name: Push Frontend Docker image |
| 32 | + run: docker push echelonkay/devops-qr-code-frontend:latest |
0 commit comments