Skip to content

Commit

Permalink
Merge pull request #8 from Pablommr/fix/subpath-empty-files
Browse files Browse the repository at this point in the history
Fix files validation in SUBPATH
  • Loading branch information
Pablommr authored Oct 23, 2024
2 parents 1384ae1 + 119dee4 commit 9a0633b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
13 changes: 10 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 All @@ -157,6 +160,10 @@ In this setup, with FILES_PATH: kubernetes, you will apply all files under the k

# Change Log

## v2.0.2

- Fix files validation in SUBPATH

## v2.0.1

- Fix to get resource name
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 9a0633b

Please sign in to comment.