-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (36 loc) · 1.44 KB
/
build-and-push-sqs-processor.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Build and Push Docker Image
on:
push:
paths:
- 'services/sqs-processor/**' # Trigger this workflow when changes occur in services/sqs-processor directory.
pull_request:
paths:
- 'services/sqs-processor/**' # Trigger this workflow for pull requests involving services/sqs-processor 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/sqs-processor"
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/sqs-processor
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