Skip to content

Commit 8f6a0ba

Browse files
authored
feat: add check for build: with image: in docker-compose.*.yaml to use DDEV offline (#81)
1 parent 89e344a commit 8f6a0ba

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.github/scripts/update-checker.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ check_tests_workflow() {
115115
fi
116116
}
117117

118+
# Check docker-compose.*.yaml files for 'build:' with 'image:' usage
119+
check_docker_compose_yaml() {
120+
local file
121+
while IFS= read -r -d '' file; do
122+
if [[ -f "$file" && -r "$file" ]]; then
123+
if grep -q "build:" "$file" && ! grep -q "image:" "$file"; then
124+
actions+=("$file contains 'build:', but there is no 'image:', example: 'image: \${ADDON_TEMPLATE_DOCKER_IMAGE:-busybox:stable}-\${DDEV_SITENAME}-built', this is required to use DDEV offline")
125+
elif grep -q "build:" "$file" && grep -q "image:" "$file" && ! grep -Eq "image:.*-\\\$\{DDEV_SITENAME\}-built" "$file"; then
126+
actions+=("$file contains both 'build:' and 'image:', but 'image:' line should contain '-\${DDEV_SITENAME}-built', example: 'image: \${ADDON_TEMPLATE_DOCKER_IMAGE:-busybox:stable}-\${DDEV_SITENAME}-built', this is required to use DDEV offline")
127+
fi
128+
fi
129+
done < <(find . -name "docker-compose.*.yaml" -print0 2>/dev/null || true)
130+
}
131+
118132
# Check for required GitHub template files
119133
check_github_templates() {
120134
local templates=(
@@ -147,6 +161,7 @@ main() {
147161
fi
148162

149163
# Check unnecessary files
164+
check_remove_file "README_ADDON.md"
150165
check_remove_file "README_DEBUG.md"
151166
check_remove_file "images/gh-tmate.jpg"
152167
check_remove_file "images/template--button.png"
@@ -158,6 +173,9 @@ main() {
158173
# Check install.yaml for conditions
159174
check_install_yaml
160175

176+
# Check docker-compose.*.yaml for conditions
177+
check_docker_compose_yaml
178+
161179
# Check tests/test.bats for conditions
162180
check_test_bats
163181

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ This repository is a quick way to get started. You can create a new repo from th
4141
10. When ready to share, make your add-on discoverable by adding the `ddev-get` [topic](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/classifying-your-repository-with-topics).
4242

4343
> [!TIP]
44-
> Run update checker in your add-on to ensure it is up-to-date:
44+
> Run the `update-checker.sh` in your add-on to ensure it is up to date:
4545
>
4646
> ```bash
4747
> curl -fsSL https://raw.githubusercontent.com/ddev/ddev-addon-template/main/.github/scripts/update-checker.sh | bash

0 commit comments

Comments
 (0)