|
8 | 8 | jobs: |
9 | 9 | build: |
10 | 10 | runs-on: ubuntu-latest |
| 11 | + |
11 | 12 | steps: |
12 | 13 | - name: Checkout repository |
13 | 14 | uses: actions/checkout@v3 |
14 | 15 |
|
| 16 | + - name: Generate Timestamp Tag |
| 17 | + id: tag |
| 18 | + run: | |
| 19 | + TAG=$(date -u +"%Y%m%d-%H%M%S") |
| 20 | + echo "IMAGE_TAG=$TAG" >> $GITHUB_ENV |
| 21 | + echo "Image tag: $TAG" |
| 22 | +
|
15 | 23 | - name: Login to Docker Hub |
16 | 24 | run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin |
17 | 25 |
|
18 | 26 | - name: Build and Push Docker Image |
19 | 27 | id: docker_build |
20 | 28 | run: | |
21 | | - docker build -t shizarizvi/texpose . |
22 | | - docker tag shizarizvi/texpose shizarizvi/texpose-app:latest |
23 | | - docker push shizarizvi/texpose-app:latest |
| 29 | + docker build -t shizarizvi/texpose:${{ env.IMAGE_TAG }} . |
| 30 | + docker tag shizarizvi/texpose:${{ env.IMAGE_TAG }} shizarizvi/texpose:latest |
| 31 | + docker push shizarizvi/texpose:${{ env.IMAGE_TAG }} |
| 32 | + docker push shizarizvi/texpose:latest |
24 | 33 | continue-on-error: true |
25 | 34 |
|
26 | 35 | - name: Send Email Notification |
27 | | - if: always() # Run this step regardless of success or failure |
| 36 | + if: always() |
28 | 37 | uses: dawidd6/action-send-mail@v3 |
29 | 38 | with: |
30 | 39 | server_address: smtp.gmail.com |
31 | 40 | server_port: 587 |
32 | 41 | username: ${{ secrets.EMAIL_USERNAME }} |
33 | 42 | password: ${{ secrets.EMAIL_PASSWORD }} |
34 | | - subject: "Docker Image Build Status: ${{ job.status }}" |
| 43 | + subject: "Docker Image Build Status: ${{ job.status }} (Tag: ${{ env.IMAGE_TAG }})" |
35 | 44 | to: "rizvi4400482@cloud.neduet.edu.pk" |
36 | 45 | from: "GitHub Actions <${{ secrets.EMAIL_USERNAME }}>" |
37 | 46 | body: | |
38 | 47 | Hello, |
39 | 48 |
|
40 | | - The Docker image build process has completed with status: ${{ job.status }} |
| 49 | + The Docker image build has completed with status: ${{ job.status }} |
41 | 50 |
|
42 | 51 | Repository: ${{ github.repository }} |
43 | 52 | Commit: ${{ github.sha }} |
44 | 53 | Branch: ${{ github.ref_name }} |
45 | 54 | Workflow: ${{ github.workflow }} |
46 | 55 | Run: ${{ github.run_id }} |
47 | 56 |
|
| 57 | + Docker Tags: |
| 58 | + - shizarizvi/texpose:${{ env.IMAGE_TAG }} |
| 59 | + - shizarizvi/texpose:latest |
| 60 | +
|
48 | 61 | Check details at: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
49 | 62 |
|
50 | 63 | Best, |
|
0 commit comments