Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create check_yaml_name.yml #239

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/check_yaml_name.yml
Original file line number Diff line number Diff line change
@@ -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
Loading