Skip to content

Commit

Permalink
Merge pull request #29 from mailsonpeixe/fix-action
Browse files Browse the repository at this point in the history
(Fix): Adding build image step in the Push phase of the pipeline
  • Loading branch information
r3kzi authored Feb 5, 2025
2 parents fdf9536 + 787c65a commit 2f4b09d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

env:
IMAGE_NAME: clamav-prometheus-exporter
IMAGE_TAG: latest

jobs:
build:
Expand Down Expand Up @@ -48,7 +49,7 @@ jobs:
# Build the Docker image
- name: Build Docker Image
run: |
docker build . -f Dockerfile -t $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
docker build . -f Dockerfile -t $IMAGE_NAME:$IMAGE_TAG
push:
name: Push Docker Image to Docker Hub
Expand All @@ -63,6 +64,11 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v3

# Build the Docker image
- name: Build Docker Image
run: |
docker build . -f Dockerfile -t $IMAGE_NAME:$IMAGE_TAG --label "runnumber=${GITHUB_RUN_ID}"
# Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
Expand All @@ -75,11 +81,11 @@ jobs:
run: |
IMAGE_ID=${{ secrets.DOCKER_HUB_USERNAME }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=latest
VERSION=$IMAGE_TAG
[[ "${{ github.ref_type }}" == "tag" ]] && VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,;s/^v//')
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
clamav-prometheus-exporter

# Test binary, built with `go test -c`
*.test
Expand All @@ -12,4 +14,4 @@
*.out

# Dependency directories (remove the comment below to include it)
vendor/
vendor/
Binary file removed clamav-prometheus-exporter
Binary file not shown.

0 comments on commit 2f4b09d

Please sign in to comment.