Skip to content

Requisite Check

Requisite Check #240

name: Requisite Check
run-name: Requisite Check
on:
pull_request:
types: [opened]
paths: 'projects/**'
jobs:
Requisite-Check:
name: Check for files
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Testing
run: |
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
FILES=$(curl -s -X GET -G $URL | jq -r '.[] | .filename')
echo $URL
echo $FILES
- name: Check for changes in project folder
run: |
if [ $length -lt 1 ]; then
echo "No files found"
exit 1
fi
project_name=$(echo $FILES[0] | cut -d'/' -f2)
echo "Project name: $project_name"
for file in $FILES; do
name=$(echo $file | cut -d'/' -f2)
echo "$name $project_name"
if [ "$name" != "$project_name" ]; then
echo "Non-project changes found"
exit 1
fi
done
exit 0
- name: Check for README.md
run: |
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
FILES=$(curl -s -X GET -G $URL | jq -r '.[] | .filename')
project_name=$(echo $FILES[0] | cut -d'/' -f2)
if echo $FILES | grep -qi "$project_name/README.md"; then
echo "README.md included"
else
echo "README.md not included"
exit 1
fi
exit 0
- name: Check for Gerbers
run: |
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
FILES=$(curl -s -X GET -G $URL | jq -r '.[] | .filename')
project_name=$(echo $FILES[0] | cut -d'/' -f2)
if echo $FILES | grep -qi "$project_name/.*.zip"; then
echo "Gerbers included"
else
echo "Gerbers not included"
exit 1
fi
exit 0
- name: Check for Vendor Approval
run: |
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
FILES=$(curl -s -X GET -G $URL | jq -r '.[] | .filename')
project_name=$(echo $FILES[0] | cut -d'/' -f2)
if echo $FILES | grep -qi "$project_name/.*.png" || echo $FILES | grep -qi "$project_name/.*.jpeg" || echo $FILES | grep -qi "$project_name/.*.tiff"; then
echo "Vendor approval included"
else
echo "Vendor approval not included"
exit 1
fi
exit 0