From 3723c83938584fce6f8e15b945a5f3b7aed737d6 Mon Sep 17 00:00:00 2001 From: raller1028 <57336867+raller1028@users.noreply.github.com> Date: Fri, 4 Aug 2023 17:13:58 +0800 Subject: [PATCH] Update check_yaml_name.yml (#241) --- .github/workflows/check_yaml_name.yml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/check_yaml_name.yml b/.github/workflows/check_yaml_name.yml index 046a43397..ece8c2dda 100644 --- a/.github/workflows/check_yaml_name.yml +++ b/.github/workflows/check_yaml_name.yml @@ -12,23 +12,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Find YAML files - id: find_yaml - run: | - yaml_files=$(find . -name "*.yaml" -o -name "*.yml" | tr '\n' ' ') - echo "::set-output name=yaml_files::$yaml_files" - - name: Check name field in YAML files id: check_name run: | - result=$(grep -oP '^name:\s(?!.*[A-Z])[a-z0-9_-]*$' ${{ steps.find_yaml.outputs.yaml_files }}) - echo "::set-output name=result::$result" - - name: Check result - run: | - if [ -z "${{ steps.check_name.outputs.result }}" ]; then - echo "There is a problem with the value of name in the submitted yaml, please make sure the value is in the range [a-z0-9_-]." - exit 1 - else - echo "name:${{ steps.check_name.outputs.result }}" - fi + find . -type f \( -name "docker-compose.yaml" -or -name "docker-compose.yml" \) | while read -r file; do + if ! grep -qP '^name:\s[a-z0-9_-]*$' "$file"; then + echo "There is a problem with the value of name in the submitted yaml, please make sure the value is in the range [a-z0-9_-]. And error file name:$file" + exit 1 + fi + done