Skip to content

Commit

Permalink
Fix files validation in SUBPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Moreira Marques committed Oct 23, 2024
1 parent 1384ae1 commit 90d2aa4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ Environment variable containing the base64-encoded kubeconfig data. Pay attentio
### `KUBE_YAML` or `FILES_PATH`

One of them (or both) must be set. <br><br>
KUBE_YAML is the path of <b>file</b> to file used to create/update the resource. This env can be an array with more then 1 file. (I.e. kubernetes/deployment.yml,artifacts/configmap.yaml )<br>
FILES_PATH is the path of the <b>directory</b> where the files are located. All files in this directory will be applied.<br><br>

KUBE_YAML is the path of <b>file</b> to file used to create/update the resource. This env can be an array with more then 1 file. (I.e. kubernetes/deployment.yml,artifacts/configmap.yaml )<br><br>

FILES_PATH is the path of the <b>directory</b> where the files are located. All files in this current directory will be applied.<br><br>

The files must be with *.yaml or *.yml extensions.

<br>
Expand Down Expand Up @@ -144,7 +147,7 @@ jobs:
uses: Pablommr/[email protected]
env:
FILES_PATH: kubernetes
KUBE_YAML: kubernetes/envs/configmap.yaml
KUBE_YAML: kubernetes/envs/prod/configmap.yaml
SUBPATH: false #Defaul value
ENVSUBST: true
KUBE_ROLLOUT: true
Expand Down
18 changes: 13 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,19 @@ check_directories_and_files() {
local dirs=("$@")
for dir in "${dirs[@]}"; do
if [ -d "$dir" ]; then
# Verifica se há pelo menos um arquivo .yaml ou .yml no diretório
if ! find "$dir" -maxdepth 1 -type f \( -name "*.yaml" -o -name "*.yml" \) | grep -q .; then
echo "No files .yaml or .yml found in dir: $dir"
echo "No files .yaml or .yml found in dir: $dir" >> $GITHUB_STEP_SUMMARY
exit 1
# Verifica se há pelo menos um arquivo .yaml ou .yml no diretório ou subdiretório
if [ "$SUBPATH" == "true" ]; then
if ! find "$dir" -type f \( -name "*.yaml" -o -name "*.yml" \) | grep -q .; then
echo "No files .yaml or .yml found in dir: $dir"
echo "No files .yaml or .yml found in dir: $dir" >> $GITHUB_STEP_SUMMARY
exit 1
fi
else
if ! find "$dir" -maxdepth 1 -type f \( -name "*.yaml" -o -name "*.yml" \) | grep -q .; then
echo "No files .yaml or .yml found in dir: $dir"
echo "No files .yaml or .yml found in dir: $dir" >> $GITHUB_STEP_SUMMARY
exit 1
fi
fi
else
echo "Path $dir doen't exist."
Expand Down

0 comments on commit 90d2aa4

Please sign in to comment.