Skip to content

Commit f608fc6

Browse files
committed
✏️ [release validation] Add a checking process of the project has Dockerfile or not and only run the Docker relative processes if it has.
1 parent ccb7d1c commit f608fc6

File tree

1 file changed

+83
-28
lines changed

1 file changed

+83
-28
lines changed

.github/workflows/rw_release_validation_complete.yaml

Lines changed: 83 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ on:
3737
value: ${{ jobs.python-build-check.result }}
3838
docker_validated:
3939
description: 'Docker validation result'
40-
value: ${{ jobs.docker-build-dockerhub.result == 'success' && jobs.docker-build-ghcr.result == 'success' }}
40+
value: ${{ jobs.check-dockerfile.outputs.has_dockerfile == 'true' && jobs.docker-build-dockerhub.result == 'success' && jobs.docker-build-ghcr.result == 'success' || jobs.check-dockerfile.outputs.has_dockerfile == 'false' }}
4141
docs_validated:
4242
description: 'Documentation validation result'
4343
value: ${{ jobs.docs-build.result }}
4444
security_validated:
4545
description: 'Security validation result'
46-
value: ${{ jobs.supply-chain-loopback.result }}
46+
value: ${{ jobs.check-dockerfile.outputs.has_dockerfile == 'true' && jobs.supply-chain-loopback.result == 'success' || jobs.check-dockerfile.outputs.has_dockerfile == 'false' }}
4747

4848
permissions:
4949
contents: read
@@ -56,6 +56,26 @@ jobs:
5656
name: Parse Configuration
5757
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_parse_project_config.yaml@master
5858

59+
check-dockerfile:
60+
name: Check Dockerfile Exists
61+
runs-on: ubuntu-latest
62+
outputs:
63+
has_dockerfile: ${{ steps.check.outputs.has_dockerfile }}
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v5
67+
68+
- name: Check for Dockerfile
69+
id: check
70+
run: |
71+
if [ -f "Dockerfile" ]; then
72+
echo "✅ Dockerfile found"
73+
echo "has_dockerfile=true" >> $GITHUB_OUTPUT
74+
else
75+
echo "⚠️ No Dockerfile found - Docker processes will be skipped"
76+
echo "has_dockerfile=false" >> $GITHUB_OUTPUT
77+
fi
78+
5979
intent-parse:
6080
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_parse_release_intent.yaml@master
6181
needs: config
@@ -85,7 +105,8 @@ jobs:
85105
docker-build-dockerhub:
86106
name: Validate DockerHub Build
87107
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_docker_operations.yaml@master
88-
needs: [config, build_git-tag_and_create_github-release]
108+
needs: [config, check-dockerfile, build_git-tag_and_create_github-release]
109+
if: needs.check-dockerfile.outputs.has_dockerfile == 'true'
89110
with:
90111
operation: 'test'
91112
registry: ${{ needs.config.outputs.docker_registry_dockerhub }}
@@ -99,7 +120,8 @@ jobs:
99120
docker-build-ghcr:
100121
name: Validate GHCR Build
101122
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_docker_operations.yaml@master
102-
needs: [config, build_git-tag_and_create_github-release]
123+
needs: [config, check-dockerfile, build_git-tag_and_create_github-release]
124+
if: needs.check-dockerfile.outputs.has_dockerfile == 'true'
103125
with:
104126
operation: 'test'
105127
registry: ${{ needs.config.outputs.docker_registry_ghcr }}
@@ -120,7 +142,8 @@ jobs:
120142
supply-chain-loopback:
121143
name: Security Scan (Supply Chain)
122144
uses: Chisanan232/Template-Python-UV-Project/.github/workflows/rw_docker_operations.yaml@master
123-
needs: [config, docker-build-dockerhub, docker-build-ghcr]
145+
needs: [config, check-dockerfile, docker-build-dockerhub, docker-build-ghcr]
146+
if: needs.check-dockerfile.outputs.has_dockerfile == 'true'
124147
with:
125148
operation: 'security-scan'
126149
registry: ${{ needs.config.outputs.docker_registry_dockerhub }} # Use DockerHub build for security scan
@@ -133,7 +156,7 @@ jobs:
133156
validation-summary:
134157
name: Validation Summary
135158
runs-on: ubuntu-latest
136-
needs: [config, intent-parse, python-build-check, docker-build-dockerhub, docker-build-ghcr, docs-build, supply-chain-loopback]
159+
needs: [config, check-dockerfile, intent-parse, python-build-check, docker-build-dockerhub, docker-build-ghcr, docs-build, supply-chain-loopback]
137160
if: always()
138161
outputs:
139162
success: ${{ steps.summary.outputs.success }}
@@ -143,32 +166,64 @@ jobs:
143166
run: |
144167
echo "=== Release Validation Summary ==="
145168
echo ""
169+
echo "Dockerfile Check: ${{ needs.check-dockerfile.outputs.has_dockerfile == 'true' && '✅ Found' || '⚠️ Not Found (Docker skipped)' }}"
146170
echo "Intent Parsing: ${{ needs.intent-parse.result }}"
147171
echo "Python Build: ${{ needs.python-build-check.result }}"
148-
echo "DockerHub Build: ${{ needs.docker-build-dockerhub.result }}"
149-
echo "GHCR Build: ${{ needs.docker-build-ghcr.result }}"
172+
173+
# Check if Docker processes were run
174+
HAS_DOCKERFILE="${{ needs.check-dockerfile.outputs.has_dockerfile }}"
175+
if [ "$HAS_DOCKERFILE" = "true" ]; then
176+
echo "DockerHub Build: ${{ needs.docker-build-dockerhub.result }}"
177+
echo "GHCR Build: ${{ needs.docker-build-ghcr.result }}"
178+
echo "Supply Chain: ${{ needs.supply-chain-loopback.result }}"
179+
else
180+
echo "DockerHub Build: ⏭️ Skipped (no Dockerfile)"
181+
echo "GHCR Build: ⏭️ Skipped (no Dockerfile)"
182+
echo "Supply Chain: ⏭️ Skipped (no Dockerfile)"
183+
fi
184+
150185
echo "Docs Build: ${{ needs.docs-build.result }}"
151-
echo "Supply Chain: ${{ needs.supply-chain-loopback.result }}"
152186
echo ""
153187
154-
if [[ "${{ needs.intent-parse.result }}" == "success" && \
155-
"${{ needs.python-build-check.result }}" == "success" && \
156-
"${{ needs.docker-build-dockerhub.result }}" == "success" && \
157-
"${{ needs.docker-build-ghcr.result }}" == "success" && \
158-
"${{ needs.docs-build.result }}" == "success" && \
159-
"${{ needs.supply-chain-loopback.result }}" == "success" ]]; then
160-
echo "✅ All validation checks passed! Release process is ready."
161-
echo "success=true" >> $GITHUB_OUTPUT
162-
echo ""
163-
echo "Release Configuration:"
164-
echo "- Do Release: ${{ needs.intent-parse.outputs.do_release }}"
165-
echo "- Level: ${{ needs.intent-parse.outputs.level }}"
166-
echo "- Python: ${{ needs.intent-parse.outputs.python }}"
167-
echo "- Docker: ${{ needs.intent-parse.outputs.docker }}"
168-
echo "- Docs: ${{ needs.intent-parse.outputs.docs }}"
169-
echo "- Notes: ${{ needs.intent-parse.outputs.notes }}"
188+
# Validate results based on whether Docker processes were expected
189+
INTENT_OK="${{ needs.intent-parse.result == 'success' }}"
190+
PYTHON_OK="${{ needs.python-build-check.result == 'success' }}"
191+
DOCS_OK="${{ needs.docs-build.result == 'success' }}"
192+
193+
if [ "$HAS_DOCKERFILE" = "true" ]; then
194+
# Docker processes should have run - validate them
195+
DOCKER_HUB_OK="${{ needs.docker-build-dockerhub.result == 'success' }}"
196+
DOCKER_GHCR_OK="${{ needs.docker-build-ghcr.result == 'success' }}"
197+
SUPPLY_CHAIN_OK="${{ needs.supply-chain-loopback.result == 'success' }}"
198+
199+
if [[ "$INTENT_OK" == "true" && "$PYTHON_OK" == "true" && \
200+
"$DOCKER_HUB_OK" == "true" && "$DOCKER_GHCR_OK" == "true" && \
201+
"$DOCS_OK" == "true" && "$SUPPLY_CHAIN_OK" == "true" ]]; then
202+
echo "✅ All validation checks passed! Release process is ready."
203+
echo "success=true" >> $GITHUB_OUTPUT
204+
else
205+
echo "❌ Some validation checks failed. Please review the logs above."
206+
echo "success=false" >> $GITHUB_OUTPUT
207+
exit 1
208+
fi
170209
else
171-
echo "❌ Some validation checks failed. Please review the logs above."
172-
echo "success=false" >> $GITHUB_OUTPUT
173-
exit 1
210+
# No Docker processes - only validate non-Docker components
211+
if [[ "$INTENT_OK" == "true" && "$PYTHON_OK" == "true" && "$DOCS_OK" == "true" ]]; then
212+
echo "✅ All validation checks passed! Release process is ready."
213+
echo "⚠️ Note: Docker validation was skipped (no Dockerfile found)"
214+
echo "success=true" >> $GITHUB_OUTPUT
215+
else
216+
echo "❌ Some validation checks failed. Please review the logs above."
217+
echo "success=false" >> $GITHUB_OUTPUT
218+
exit 1
219+
fi
174220
fi
221+
222+
echo ""
223+
echo "Release Configuration:"
224+
echo "- Do Release: ${{ needs.intent-parse.outputs.do_release }}"
225+
echo "- Level: ${{ needs.intent-parse.outputs.level }}"
226+
echo "- Python: ${{ needs.intent-parse.outputs.python }}"
227+
echo "- Docker: ${{ needs.intent-parse.outputs.docker }}"
228+
echo "- Docs: ${{ needs.intent-parse.outputs.docs }}"
229+
echo "- Notes: ${{ needs.intent-parse.outputs.notes }}"

0 commit comments

Comments
 (0)