From 39e73f4f7f49fb5191c822d5b3fe3b118abbf207 Mon Sep 17 00:00:00 2001 From: raller1028 <57336867+raller1028@users.noreply.github.com> Date: Fri, 4 Aug 2023 16:09:04 +0800 Subject: [PATCH] Create check_yaml_name.yml --- .github/workflows/check_yaml_name.yml | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/check_yaml_name.yml diff --git a/.github/workflows/check_yaml_name.yml b/.github/workflows/check_yaml_name.yml new file mode 100644 index 000000000..046a43397 --- /dev/null +++ b/.github/workflows/check_yaml_name.yml @@ -0,0 +1,34 @@ +name: PR Check YAML + +on: + pull_request: + types: [opened, synchronize] + +jobs: + check_yaml: + runs-on: ubuntu-22.04 + + steps: + - 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