Skip to content

Commit 02bf1d0

Browse files
committed
feat: update smurf shared workflows for docker, helm and terraform and update document
1 parent f6ef7e5 commit 02bf1d0

6 files changed

Lines changed: 1278 additions & 291 deletions

File tree

.github/workflows/docker-smurf.yml

Lines changed: 67 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
2-
name: 🦸‍♂️ Smurf-Docker
3-
'on':
2+
name: Smurf-Docker
3+
4+
on:
45
workflow_call:
56
inputs:
67
docker_enable:
@@ -54,7 +55,7 @@ name: 🦸‍♂️ Smurf-Docker
5455
description: 'The URL of the container registry (e.g., Docker Hub, ECR, GCR, ACR).'
5556
type: string
5657
dockerfile_path:
57-
description: Docker file directory
58+
description: Docker file path (relative to repo root)
5859
type: string
5960
default: Dockerfile
6061
docker_build_args:
@@ -113,6 +114,9 @@ name: 🦸‍♂️ Smurf-Docker
113114
AWS_SESSION_TOKEN:
114115
required: false
115116
description: AWS Session Token for direct authentication
117+
BUILD_ROLE:
118+
required: false
119+
description: AWS OIDC role for aws authentication
116120
GCP_WIP:
117121
required: false
118122
description: 'WIP Connected with Service Account'
@@ -125,6 +129,12 @@ name: 🦸‍♂️ Smurf-Docker
125129
GCP_SERVICE_ACCOUNT_KEY:
126130
required: false
127131
description: 'GCP service account JSON Key'
132+
DOCKER_USERNAME:
133+
required: false
134+
description: Docker Hub username
135+
DOCKER_PASSWORD:
136+
required: false
137+
description: Docker Hub access token or password
128138
aws_set_parameters:
129139
required: false
130140
description: Overriding the default values using --set flag
@@ -137,37 +147,39 @@ jobs:
137147
id-token: write
138148
contents: read
139149
steps:
140-
- name: 📦 Checkout
150+
- name: Checkout
141151
uses: actions/checkout@v6
142152

143-
# - Setup smurf CLI
144153
- name: Setup Smurf
145-
uses: clouddrove/smurf@v1.1.3
154+
uses: clouddrove/smurf@v1.1.5
146155

147-
- name: 🐳 Docker Image Build
156+
- name: Docker Image Build
148157
if: inputs.docker_buildkit_enable != 'true'
149158
run: |
150-
smurf sdkr build ${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }} -f ${{
151-
inputs.dockerfile_path }} --platform ${{ inputs.docker_build_platform }}
159+
smurf sdkr build ${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }} \
160+
-f ${{ inputs.dockerfile_path }} \
161+
--platform ${{ inputs.docker_build_platform }} \
152162
--build-arg ${{ inputs.docker_build_args }}
153163
154-
- name: 🐳 Docker Image Build with Buildkit
164+
- name: Docker Image Build with Buildkit
155165
if: inputs.docker_buildkit_enable == 'true'
156166
run: |
157-
smurf sdkr build ${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }} -f ${{
158-
inputs.dockerfile_path }} --platform ${{ inputs.docker_build_platform }}
159-
--build-arg ${{ inputs.docker_build_args }} --buildkit
167+
smurf sdkr build ${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }} \
168+
-f ${{ inputs.dockerfile_path }} \
169+
--platform ${{ inputs.docker_build_platform }} \
170+
--build-arg ${{ inputs.docker_build_args }} \
171+
--buildkit
160172
161-
- name: 💾 Save Docker Image as Artifact
162-
run: >
163-
docker save ${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }} -o ${{
164-
inputs.docker_image_tar }}
173+
- name: Save Docker Image as Artifact
174+
run: |
175+
docker save ${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }} \
176+
-o ${{ inputs.docker_image_tar }}
165177
166-
- name: ⬆️ Upload Docker Image Artifact
178+
- name: Upload Docker Image Artifact
167179
uses: actions/upload-artifact@v7
168180
with:
169-
name: '${{ inputs.docker_image_name }}'
170-
path: '${{ inputs.docker_image_tar }}'
181+
name: docker-image
182+
path: ${{ inputs.docker_image_tar }}
171183

172184
docker_scan_push:
173185
if: inputs.docker_enable == 'true' && inputs.docker_push == 'true'
@@ -177,23 +189,21 @@ jobs:
177189
id-token: write
178190
contents: read
179191
steps:
180-
- name: 📦 Checkout
192+
- name: Checkout
181193
uses: actions/checkout@v6
182194

183-
# - Setup smurf CLI
184195
- name: Setup Smurf
185-
uses: clouddrove/smurf@v1.1.3
196+
uses: clouddrove/smurf@v1.1.5
186197

187-
- name: ⬇️ Download Docker Image Artifact
198+
- name: Download Docker Image Artifact
188199
uses: actions/download-artifact@v8
189200
with:
190-
name: '${{ inputs.docker_image_name }}'
201+
name: docker-image
191202

192-
- name: 📥 Load Docker Image
193-
run: |
194-
docker load -i ${{ inputs.docker_image_tar }}
203+
- name: Load Docker Image
204+
run: docker load -i ${{ inputs.docker_image_tar }}
195205

196-
- name: 🟦 Install AWS CLI
206+
- name: Install AWS CLI
197207
if: ${{ inputs.provider == 'aws' }}
198208
uses: aws-actions/configure-aws-credentials@v6
199209
with:
@@ -205,14 +215,14 @@ jobs:
205215
role-duration-seconds: 900
206216
role-skip-session-tagging: true
207217

208-
- name: 🔄 Assume another IAM Role
218+
- name: Assume another IAM Role
209219
if: inputs.aws_assume_role == 'true'
210220
uses: aws-actions/configure-aws-credentials@v6
211221
with:
212222
role-to-assume: ${{ inputs.aws_assume_role_arn }}
213223
aws-region: ${{ inputs.aws_region }}
214224

215-
- name: ☁️ Authenticate Google Cloud with WIP and Service Account
225+
- name: Authenticate Google Cloud with WIP and Service Account
216226
if: inputs.gcp_auth_method == 'wip'
217227
uses: google-github-actions/auth@v3
218228
with:
@@ -222,31 +232,42 @@ jobs:
222232
access_token_lifetime: 300s
223233
project_id: ${{ inputs.gcp_project_id }}
224234

225-
- name: ☁️ Authenticate Google Cloud with Service Account JSON Key
235+
- name: Authenticate Google Cloud with Service Account JSON Key
226236
if: inputs.gcp_auth_method == 'json'
227-
uses: 'google-github-actions/auth@v3'
237+
uses: google-github-actions/auth@v3
228238
with:
229-
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'
239+
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
240+
241+
- name: Set Docker Hub environment variables
242+
if: inputs.docker_registry == 'hub'
243+
run: |
244+
echo "DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }}" >> $GITHUB_ENV
245+
echo "DOCKER_PASSWORD=${{ secrets.DOCKER_PASSWORD }}" >> $GITHUB_ENV
246+
shell: bash
247+
248+
- name: Install Trivy
249+
run: |
250+
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
251+
trivy --version
230252
231-
- name: 🛡️ Docker Image Scan
253+
- name: Docker Image Scan
232254
run: |
233255
smurf sdkr scan ${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }}
234256
235-
- name: 🏷️ Docker Image Tag
257+
- name: Docker Image Tag
236258
if: inputs.docker_push == 'true'
237259
run: |
238-
smurf sdkr tag ${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }} ${{
239-
inputs.docker_registry_url }}/${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }}
260+
smurf sdkr tag ${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }} \
261+
${{ inputs.docker_registry_url }}/${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }}
240262
241-
- name: 🚀 Docker Image Push
242-
if: inputs.docker_push == 'true' && inputs.gcp_docker_push != 'true'
263+
- name: Docker Image Push
264+
if: inputs.docker_push == 'true' && inputs.gcp_docker_push != 'true'
243265
run: |
244-
smurf sdkr push ${{ inputs.docker_registry }} ${{ inputs.docker_registry_url }}/${{ inputs.docker_image_name }}:${{
245-
inputs.docker_image_tag }}
266+
smurf sdkr push ${{ inputs.docker_registry }} ${{ inputs.docker_registry_url }}/${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }}
246267
247-
- name: 🚀 Docker Image Push on gcp
268+
- name: Docker Image Push on gcp
248269
if: inputs.docker_push == 'true' && inputs.gcp_docker_push == 'true'
249270
run: |
250-
smurf sdkr push ${{ inputs.docker_registry }} ${{ inputs.docker_registry_url }}/${{ inputs.docker_image_name }}:${{
251-
inputs.docker_image_tag }} --project-id ${{ inputs.gcp_project_id }}
252-
...
271+
smurf sdkr push ${{ inputs.docker_registry }} \
272+
${{ inputs.docker_registry_url }}/${{ inputs.docker_image_name }}:${{ inputs.docker_image_tag }} \
273+
--project-id ${{ inputs.gcp_project_id }}

0 commit comments

Comments
 (0)