diff --git a/scripts/write-argocd-repo/run.sh b/scripts/write-argocd-repo/run.sh index 888b358..4153603 100755 --- a/scripts/write-argocd-repo/run.sh +++ b/scripts/write-argocd-repo/run.sh @@ -5,31 +5,34 @@ repo_root="$(git rev-parse --show-toplevel)" cd "${repo_root}" output_dir="${repo_root}/bootstrap" -output_file="${output_dir}/repo.yaml" -workflow_dir="${repo_root}/.gitea/workflows" +output_file="${output_dir}/badge.yaml" +workflow_file="${repo_root}/.gitea/workflows/validate.yaml" -mkdir -p "${output_dir}" -origin_url="$(git remote get-url origin 2>/dev/null || true)" +origin_url="$(git remote get-url origin | sed 's/git\@git\.olb42\.com\:/https:\/\/git.olb42.com\//' | sed 's/\.git$//' 2>/dev/null || true)" branch="$(git symbolic-ref --quiet --short HEAD 2>/dev/null || git rev-parse --short HEAD)" -workflow_files=() - -if [[ -d "${workflow_dir}" ]]; then - while IFS= read -r -d '' file; do - workflow_files+=("${file#${workflow_dir}/}") - done < <(find "${workflow_dir}" -maxdepth 1 -type f -print0 | sort -z) +if [[ -f $workflow_file ]]; then + mkdir -p "${output_dir}" + printf "badge=%s/actions/workflows/%s/badge.svg%s\n" "${_origin_url}" "${_workflow_file:-validate.yaml}" "${_branch}" > $output_file + git add "${output_file}" fi -{ - printf 'remote_origin_url=%s\n' "${origin_url}" - printf 'branch=%s\n' "${branch}" +#if [[ -d "${workflow_dir}" ]]; then +# while IFS= read -r -d '' file; do +# workflow_files+=("${file#${workflow_dir}/}") +# done < <(find "${workflow_dir}" -maxdepth 1 -type f -print0 | sort -z) +#fi - if (( ${#workflow_files[@]} > 0 )); then - printf 'workflow_files=%s\n' "$(IFS=,; echo "${workflow_files[*]}")" - else - printf 'workflow_files=\n' - fi -} > "${output_file}" +#{ +# printf 'remote_origin_url=%s\n' "${origin_url}" +# printf 'branch=%s\n' "${branch}" +# +# if (( ${#workflow_files[@]} > 0 )); then +# printf 'workflow_files=%s\n' "$(IFS=,; echo "${workflow_files[*]}")" +# else +# printf 'workflow_files=\n' +# fi +#} > "${output_file}" -git add "${output_file}" +#git add "${output_file}"