|
1 | | -name: Build and Publish Image to Docker Hub |
| 1 | +name: Build and Publish Docker Images |
2 | 2 |
|
3 | 3 | on: |
4 | | - [workflow_dispatch] # This allows manual triggering from GitHub UI |
| 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 |
5 | 14 |
|
6 | 15 | jobs: |
7 | | - publish_images: |
| 16 | + build_and_push_images: |
8 | 17 | runs-on: ubuntu-latest |
| 18 | + |
9 | 19 | steps: |
10 | | - - name: Checkout repository |
| 20 | + # Step 1: Checkout repository |
| 21 | + - name: Checkout Repository |
11 | 22 | uses: actions/checkout@v4 |
12 | | - |
| 23 | + |
| 24 | + # Step 2: Log in to Docker Hub |
13 | 25 | - name: Log in to Docker Hub |
14 | | - run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "echelonkay" --password-stdin |
15 | | - |
16 | | - - name: Build API image |
17 | | - run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest --no-cache |
18 | | - |
19 | | - - name: Build Frontend image |
20 | | - run: docker build ./front-end-nextjs/ -t echelonkay/devops-qr-code-frontend:latest --no-cache |
21 | | - |
22 | | - - name: Push API image to Docker Hub |
23 | | - run: docker push echelonkay/devops-qr-code-api:latest |
24 | | - |
25 | | - - name: Push Frontend image to Docker Hub |
26 | | - run: docker push echelonkay/devops-qr-code-frontend:latest |
| 26 | + uses: docker/login-action@v2 |
| 27 | + with: |
| 28 | + username: echelonkay |
| 29 | + password: ${{ secrets.DOCKER_HUB_TOKEN }} |
| 30 | + |
| 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 |
| 38 | +
|
| 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 |
| 44 | +
|
| 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 |
| 52 | +
|
| 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 |
0 commit comments