1- name : SDK - Build and Push containers
1+ name : ' SDK: Container Build and Push'
22
33on :
44 push :
55 branches :
6- # For `v3-latest`
7- - " v3"
8- # For `v4-latest`
9- - " v4.6"
10- # For `latest`
11- - " master"
6+ - ' v3' # For v3-latest
7+ - ' v4.6' # For v4-latest
8+ - ' master' # For latest
129 paths-ignore :
13- - " .github/**"
14- - " README.md "
15- - " docs/** "
16- - " ui /**"
17- - " api /**"
18-
10+ - ' .github/**'
11+ - ' !.github/workflows/sdk-container-build-push.yml '
12+ - ' README.md '
13+ - ' docs /**'
14+ - ' ui /**'
15+ - ' api/** '
1916 release :
20- types : [published]
17+ types :
18+ - ' published'
2119
22- env :
23- # AWS Configuration
24- AWS_REGION_STG : eu-west-1
25- AWS_REGION_PLATFORM : eu-west-1
26- AWS_REGION : us-east-1
20+ permissions :
21+ contents : read
22+
23+ concurrency :
24+ group : ${{ github.workflow }}-${{ github.ref }}
25+ cancel-in-progress : true
2726
28- # Container's configuration
27+ env :
28+ # Container configuration
2929 IMAGE_NAME : prowler
3030 DOCKERFILE_PATH : ./Dockerfile
3131
32- # Tags
32+ # Python configuration
33+ PYTHON_VERSION : ' 3.12'
34+
35+ # Tags (dynamically set based on version)
3336 LATEST_TAG : latest
3437 STABLE_TAG : stable
35- # The RELEASE_TAG is set during runtime in releases
36- RELEASE_TAG : " "
37- # The PROWLER_VERSION and PROWLER_VERSION_MAJOR are set during runtime in releases
38- PROWLER_VERSION : " "
39- PROWLER_VERSION_MAJOR : " "
40- # TEMPORARY_TAG: temporary
4138
42- # Python configuration
43- PYTHON_VERSION : 3.12
44-
45- # Container Registries
39+ # Container registries
4640 PROWLERCLOUD_DOCKERHUB_REPOSITORY : prowlercloud
4741 PROWLERCLOUD_DOCKERHUB_IMAGE : prowler
4842
43+ # AWS configuration (for ECR)
44+ AWS_REGION : us-east-1
45+
4946jobs :
50- # Build Prowler OSS container
5147 container-build-push :
52- # needs: dockerfile-linter
48+ if : github.repository == 'prowler-cloud/prowler'
5349 runs-on : ubuntu-latest
50+ timeout-minutes : 45
51+ permissions :
52+ contents : read
53+ packages : write
5454 outputs :
55- prowler_version_major : ${{ steps.get-prowler-version.outputs.PROWLER_VERSION_MAJOR }}
56- prowler_version : ${{ steps.get-prowler-version.outputs.PROWLER_VERSION }}
55+ prowler_version : ${{ steps.get-prowler-version.outputs.prowler_version }}
56+ prowler_version_major : ${{ steps.get-prowler-version.outputs.prowler_version_major }}
5757 env :
58- POETRY_VIRTUALENVS_CREATE : " false"
58+ POETRY_VIRTUALENVS_CREATE : ' false'
5959
6060 steps :
61- - name : Checkout
61+ - name : Checkout repository
6262 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
6363
64- - name : Setup Python
64+ - name : Set up Python ${{ env.PYTHON_VERSION }}
6565 uses : actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
6666 with :
6767 python-version : ${{ env.PYTHON_VERSION }}
6868
6969 - name : Install Poetry
7070 run : |
71- pipx install poetry==2.*
71+ pipx install poetry==2.1.1
7272 pipx inject poetry poetry-bumpversion
7373
74- - name : Get Prowler version
74+ - name : Get Prowler version and set tags
7575 id : get-prowler-version
7676 run : |
7777 PROWLER_VERSION="$(poetry version -s 2>/dev/null)"
78+ echo "prowler_version=${PROWLER_VERSION}" >> "${GITHUB_OUTPUT}"
7879 echo "PROWLER_VERSION=${PROWLER_VERSION}" >> "${GITHUB_ENV}"
79- echo "PROWLER_VERSION=${PROWLER_VERSION}" >> "${GITHUB_OUTPUT}"
8080
81- # Store prowler version major just for the release
81+ # Extract major version
8282 PROWLER_VERSION_MAJOR="${PROWLER_VERSION%%.*}"
83+ echo "prowler_version_major=${PROWLER_VERSION_MAJOR}" >> "${GITHUB_OUTPUT}"
8384 echo "PROWLER_VERSION_MAJOR=${PROWLER_VERSION_MAJOR}" >> "${GITHUB_ENV}"
84- echo "PROWLER_VERSION_MAJOR=${PROWLER_VERSION_MAJOR}" >> "${GITHUB_OUTPUT}"
8585
86+ # Set version-specific tags
8687 case ${PROWLER_VERSION_MAJOR} in
87- 3)
88+ 3)
8889 echo "LATEST_TAG=v3-latest" >> "${GITHUB_ENV}"
8990 echo "STABLE_TAG=v3-stable" >> "${GITHUB_ENV}"
91+ echo "✓ Prowler v3 detected - tags: v3-latest, v3-stable"
9092 ;;
91-
92-
93- 4)
93+ 4)
9494 echo "LATEST_TAG=v4-latest" >> "${GITHUB_ENV}"
9595 echo "STABLE_TAG=v4-stable" >> "${GITHUB_ENV}"
96+ echo "✓ Prowler v4 detected - tags: v4-latest, v4-stable"
9697 ;;
97-
98- 5)
98+ 5)
9999 echo "LATEST_TAG=latest" >> "${GITHUB_ENV}"
100100 echo "STABLE_TAG=stable" >> "${GITHUB_ENV}"
101+ echo "✓ Prowler v5 detected - tags: latest, stable"
101102 ;;
102-
103- *)
104- # Fallback if any other version is present
105- echo "Releasing another Prowler major version, aborting..."
103+ *)
104+ echo "::error::Unsupported Prowler major version: ${PROWLER_VERSION_MAJOR}"
106105 exit 1
107106 ;;
108107 esac
@@ -125,26 +124,26 @@ jobs:
125124 - name : Set up Docker Buildx
126125 uses : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
127126
128- - name : Build and push container image (latest)
127+ - name : Build and push SDK container (latest)
129128 if : github.event_name == 'push'
130129 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
131130 with :
131+ context : .
132+ file : ${{ env.DOCKERFILE_PATH }}
132133 push : true
133134 tags : |
134135 ${{ secrets.DOCKER_HUB_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ env.LATEST_TAG }}
135136 ${{ secrets.PUBLIC_ECR_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ env.LATEST_TAG }}
136137 ${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${{ env.LATEST_TAG }}
137- file : ${{ env.DOCKERFILE_PATH }}
138138 cache-from : type=gha
139139 cache-to : type=gha,mode=max
140140
141- - name : Build and push container image (release)
141+ - name : Build and push SDK container (release)
142142 if : github.event_name == 'release'
143143 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
144144 with :
145- # Use local context to get changes
146- # https://github.com/docker/build-push-action#path-context
147145 context : .
146+ file : ${{ env.DOCKERFILE_PATH }}
148147 push : true
149148 tags : |
150149 ${{ secrets.DOCKER_HUB_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ env.PROWLER_VERSION }}
@@ -153,50 +152,36 @@ jobs:
153152 ${{ secrets.PUBLIC_ECR_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ env.STABLE_TAG }}
154153 ${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${{ env.PROWLER_VERSION }}
155154 ${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${{ env.STABLE_TAG }}
156- file : ${{ env.DOCKERFILE_PATH }}
157155 cache-from : type=gha
158156 cache-to : type=gha,mode=max
159157
160- # - name: Push README to Docker Hub (toniblyx)
161- # uses: peter-evans/dockerhub-description@432a30c9e07499fd01da9f8a49f0faf9e0ca5b77 # v4.0.2
162- # with:
163- # username: ${{ secrets.DOCKERHUB_USERNAME }}
164- # password: ${{ secrets.DOCKERHUB_TOKEN }}
165- # repository: ${{ env.DOCKER_HUB_REPOSITORY }}/${{ env.IMAGE_NAME }}
166- # readme-filepath: ./README.md
167- #
168- # - name: Push README to Docker Hub (prowlercloud)
169- # uses: peter-evans/dockerhub-description@432a30c9e07499fd01da9f8a49f0faf9e0ca5b77 # v4.0.2
170- # with:
171- # username: ${{ secrets.DOCKERHUB_USERNAME }}
172- # password: ${{ secrets.DOCKERHUB_TOKEN }}
173- # repository: ${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}
174- # readme-filepath: ./README.md
175-
176- dispatch-action :
158+ dispatch-v3-deployment :
159+ if : needs.container-build-push.outputs.prowler_version_major == '3'
177160 needs : container-build-push
178161 runs-on : ubuntu-latest
162+ timeout-minutes : 5
163+ permissions :
164+ contents : read
165+
179166 steps :
180- - name : Get latest commit info (latest)
167+ - name : Calculate short SHA
168+ id : short-sha
169+ run : echo "short_sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
170+
171+ - name : Dispatch v3 deployment (latest)
181172 if : github.event_name == 'push'
182- run : |
183- LATEST_COMMIT_HASH=$(echo ${{ github.event.after }} | cut -b -7)
184- echo "LATEST_COMMIT_HASH=${LATEST_COMMIT_HASH}" >> $GITHUB_ENV
173+ uses : peter-evans/repository-dispatch@5fc4efd1a4797ddb68ffd0714a238564e4cc0e6f # v4.0.0
174+ with :
175+ token : ${{ secrets.PROWLER_BOT_ACCESS_TOKEN }}
176+ repository : ${{ secrets.DISPATCH_OWNER }}/${{ secrets.DISPATCH_REPO }}
177+ event-type : dispatch
178+ client-payload : ' {"version":"v3-latest","tag":"${{ steps.short-sha.outputs.short_sha }}"}'
185179
186- - name : Dispatch event (latest)
187- if : github.event_name == 'push' && needs.container-build-push.outputs.prowler_version_major == '3'
188- run : |
189- curl https://api.github.com/repos/${{ secrets.DISPATCH_OWNER }}/${{ secrets.DISPATCH_REPO }}/dispatches \
190- -H "Accept: application/vnd.github+json" \
191- -H "Authorization: Bearer ${{ secrets.PROWLER_BOT_ACCESS_TOKEN }}" \
192- -H "X-GitHub-Api-Version: 2022-11-28" \
193- --data '{"event_type":"dispatch","client_payload":{"version":"v3-latest", "tag": "${{ env.LATEST_COMMIT_HASH }}"}}'
194-
195- - name : Dispatch event (release)
196- if : github.event_name == 'release' && needs.container-build-push.outputs.prowler_version_major == '3'
197- run : |
198- curl https://api.github.com/repos/${{ secrets.DISPATCH_OWNER }}/${{ secrets.DISPATCH_REPO }}/dispatches \
199- -H "Accept: application/vnd.github+json" \
200- -H "Authorization: Bearer ${{ secrets.PROWLER_BOT_ACCESS_TOKEN }}" \
201- -H "X-GitHub-Api-Version: 2022-11-28" \
202- --data '{"event_type":"dispatch","client_payload":{"version":"release", "tag":"${{ needs.container-build-push.outputs.prowler_version }}"}}'
180+ - name : Dispatch v3 deployment (release)
181+ if : github.event_name == 'release'
182+ uses : peter-evans/repository-dispatch@5fc4efd1a4797ddb68ffd0714a238564e4cc0e6f # v4.0.0
183+ with :
184+ token : ${{ secrets.PROWLER_BOT_ACCESS_TOKEN }}
185+ repository : ${{ secrets.DISPATCH_OWNER }}/${{ secrets.DISPATCH_REPO }}
186+ event-type : dispatch
187+ client-payload : ' {"version":"release","tag":"${{ needs.container-build-push.outputs.prowler_version }}"}'
0 commit comments