Update check_yaml_name.yml (#241)

This commit is contained in:
raller1028 2023-08-04 17:13:58 +08:00 committed by GitHub
parent 673d7da1e7
commit 3723c83938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 16 deletions

View File

@ -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