Skip to content

Commit

Permalink
fix: Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-castro committed Nov 10, 2024
1 parent d67c601 commit df6ac9a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 36 deletions.
33 changes: 33 additions & 0 deletions .github/actions/build-and-push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and push
description: Build and push Docker images to Docker Hub

inputs:
environment:
description: "Environment to build images for"
required: true
service:
description: "Service to build and push"
required: true

runs:
using: "composite"
steps:
- name: Check inputs
shell: bash
if: ${{ inputs.environment != 'dev' && inputs.environment != 'prod' }}
run: echo "Wrong environment. Expected 'dev' or 'prod', got '${{ inputs.environment }}'" && exit 1

- name: Checkout repository
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push backend image
shell: bash
run: |
docker build -t healthcheck-${{ matrix.service }}:${{ inputs.environment }} ${{ matrix.service }}
docker push healthcheck-${{ matrix.service }}:${{ inputs.environment }}
6 changes: 5 additions & 1 deletion .github/workflows/build-and-push-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service: [frontend, backend]
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build and push dev images
uses: ./.github/workflows/build-and-push.yml
uses: ./.github/actions/build-and-push
with:
environment: "dev"
service: ${{ matrix.service }}
6 changes: 5 additions & 1 deletion .github/workflows/build-and-push-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service: [frontend, backend]
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Build and push prod images
uses: ./.github/workflows/build-and-push.yml
uses: ./.github/actions/build-and-push
with:
environment: "prod"
service: ${{ matrix.service }}

34 changes: 0 additions & 34 deletions .github/workflows/build-and-push.yml

This file was deleted.

0 comments on commit df6ac9a

Please sign in to comment.