1+ name : Build and Push Docker Image
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ build-and-push :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v2
15+
16+ - name : Set up Docker Buildx
17+ uses : docker/setup-buildx-action@v1
18+
19+ - name : Login to Docker Hub
20+ uses : docker/login-action@v1
21+ with :
22+ username : ${{ secrets.DOCKER_USERNAME }}
23+ password : ${{ secrets.DOCKER_PASSWORD }}
24+
25+ - name : Build and push Docker image
26+ uses : docker/build-push-action@v2
27+ with :
28+ context : .
29+ file : ./Dockerfile
30+ push : true
31+ tags : ${{ secrets.DOCKER_USERNAME }}/fleet-telemetry-consumer:latest
32+
33+
34+
35+ name : Build and Push Docker Image
36+
37+ on :
38+ push :
39+ branches :
40+ - " **" # Triggers on all branches
41+ tags :
42+ - " v*.*.*" # Triggers on tag push for versioned tags (e.g., v1.0.0)
43+
44+ jobs :
45+ build :
46+ runs-on : ubuntu-latest
47+ steps :
48+ - name : Checkout code
49+ uses : actions/checkout@v3
50+
51+ - name : Set up Docker Buildx
52+ uses : docker/setup-buildx-action@v2
53+
54+ - name : Log in to Quay.io
55+ run : echo "${{ secrets.DOCKER_PASSWORD }}" | docker login quay.io -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
56+
57+ - name : Get tag or commit SHA
58+ id : vars
59+ run : |
60+ if [ "${{ github.event_name }}" = "push" ] && [ -n "${{ github.ref_name }}" ]; then
61+ echo "image_tag=${{ github.ref_name }}" >> $GITHUB_ENV
62+ else
63+ echo "image_tag=${{ github.sha }}" >> $GITHUB_ENV
64+ fi
65+
66+ - name : Build Docker Image
67+ run : make build
68+
69+ - name : Tag Docker Image
70+ run : docker tag fleet-telemetry-consumer quay.io/rajsinghcpre/fleet-telemetry-consumer:${{ env.image_tag }}
71+
72+ - name : Push Docker Image
73+ run : docker push quay.io/rajsinghcpre/fleet-telemetry-consumer:${{ env.image_tag }}
0 commit comments