services moved into services
folder
#1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Docker Image | |
on: | |
push: | |
paths: | |
- 'services/name/**' # Trigger this workflow when changes occur in services/name directory. | |
pull_request: | |
paths: | |
- 'services/name/**' # Trigger this workflow for pull requests involving services/name directory. | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the code from the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 2: Set up Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Step 3: Log in to Docker Hub | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
# Step 4: Build and push Docker image using commit SHA as tag | |
- name: Build and push Docker image | |
run: | | |
IMAGE_NAME="juanroldan1989/name" | |
IMAGE_TAG=$(git rev-parse --short HEAD) # Use short commit SHA as tag | |
echo "Building Docker image with tag $IMAGE_TAG" | |
docker build -t $IMAGE_NAME:$IMAGE_TAG ./services/name | |
echo "Pushing Docker image $IMAGE_NAME:$IMAGE_TAG" | |
docker push $IMAGE_NAME:$IMAGE_TAG | |
# Step 5: Clean up Docker images | |
- name: Clean up Docker images | |
run: docker rmi $IMAGE_NAME:$IMAGE_TAG |