Skip to content

Commit cbc2e7c

Browse files
authored
Enhance repo structure check for PR branches
Updated the script to check for required files in the PR branch and collect missing files in an array.
1 parent befd992 commit cbc2e7c

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/repo-structure-check.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,36 @@ jobs:
1515
env:
1616
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1717
run: |
18-
missing=false
18+
missing_files=()
1919
2020
required_files=(
2121
"README.md"
2222
"CONTRIBUTING.md"
2323
".gitignore"
2424
)
2525
26-
echo "Checking required files in ${{ github.repository }}"
26+
echo "Checking required files in PR branch: ${{ github.head_ref }}"
2727
2828
for file in "${required_files[@]}"; do
2929
echo "Checking $file..."
3030
3131
status=$(curl -s -o /dev/null -w "%{http_code}" \
3232
-H "Authorization: token $GH_TOKEN" \
33-
https://api.github.com/repos/${{ github.repository }}/contents/$file)
33+
"https://api.github.com/repos/${{ github.repository }}/contents/$file?ref=${{ github.head_ref }}")
3434
3535
if [ "$status" != "200" ]; then
3636
echo "Missing: $file"
37-
missing=true
37+
missing_files+=("$file")
3838
else
3939
echo "Found $file"
4040
fi
4141
done
4242
43-
if [ "$missing" = true ]; then
44-
echo "One or more required files are missing."
43+
if [ ${#missing_files[@]} -gt 0 ]; then
44+
echo "Missing files:"
45+
for f in "${missing_files[@]}"; do
46+
echo " - $f"
47+
done
4548
exit 1
4649
fi
4750

0 commit comments

Comments
 (0)