Skip to content

fix: remove trailing space from directory name causing Windows git clone failure #38

fix: remove trailing space from directory name causing Windows git clone failure

fix: remove trailing space from directory name causing Windows git clone failure #38

name: PR Compliance Check
on:
pull_request:
paths:
- '01-Identity and Access Management/**'
- '02-Security/**'
- '03-Azure/**'
- '04-Microsoft-365/**'
permissions:
contents: read
pull-requests: write
jobs:
compliance-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v46
with:
write_output_files: true
separator: "\n"
files: |
01-Identity and Access Management/**
02-Security/**
03-Azure/**
04-Microsoft-365/**
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install brokelink
run: pip install brokelink beautifulsoup4 colorama click
- name: Check markdown links and images
id: brokelink-check
continue-on-error: true
run: |
echo "## Brokelink Check Results" > brokelink-results.md
echo "" >> brokelink-results.md
EXIT_CODE=0
while IFS= read -r file; do
[ -z "$file" ] && continue
if [[ "$file" == *.md ]]; then
echo "Checking: $file"
OUTPUT=$(brokelink "$file" --include="*.md" --check-images 2>&1) || FILE_EXIT=$?
FILE_EXIT=${FILE_EXIT:-0}
if [ "$FILE_EXIT" -ne 0 ]; then
echo "❌ **$file** - Issues found" >> brokelink-results.md
echo '```' >> brokelink-results.md
echo "$OUTPUT" >> brokelink-results.md
echo '```' >> brokelink-results.md
echo "" >> brokelink-results.md
EXIT_CODE=1
else
echo "✅ **$file** - OK" >> brokelink-results.md
fi
fi
done < .github/outputs/all_changed_files.txt
echo "BROKELINK_EXIT_CODE=$EXIT_CODE" >> $GITHUB_OUTPUT
cat brokelink-results.md
- name: Run file structure compliance check
id: structure-check
run: |
python .github/scripts/check_file_structure.py < .github/outputs/all_changed_files.txt
continue-on-error: true
- name: Upload compliance summary
if: always()
run: |
if [ -f structure-check-results.md ]; then
cat structure-check-results.md >> $GITHUB_STEP_SUMMARY
fi
if [ -f brokelink-results.md ]; then
cat brokelink-results.md >> $GITHUB_STEP_SUMMARY
fi
- name: Check final compliance status
id: final-status
run: |
BROKELINK_STATUS=${{ steps.brokelink-check.outputs.BROKELINK_EXIT_CODE }}
STRUCTURE_STATUS=${{ steps.structure-check.outcome }}
if [ "$BROKELINK_STATUS" != "0" ] || [ "$STRUCTURE_STATUS" == "failure" ]; then
echo "COMPLIANCE_FAILED=true" >> $GITHUB_OUTPUT
echo "❌ Compliance check failed"
else
echo "COMPLIANCE_FAILED=false" >> $GITHUB_OUTPUT
echo "✅ All compliance checks passed"
fi
- name: Build PR comment body
if: steps.final-status.outputs.COMPLIANCE_FAILED == 'true'
run: |
{
echo '## ❌ PR Compliance Check Failed'
echo ''
echo 'Please fix the following issues before merging:'
echo ''
if [ -f structure-check-results.md ]; then
cat structure-check-results.md
echo ''
fi
if [ -f brokelink-results.md ]; then
cat brokelink-results.md
fi
echo ''
echo '---'
echo '*This comment was automatically generated by the PR Compliance Check workflow.*'
} > pr-comment.md
- name: Post comment on PR
if: steps.final-status.outputs.COMPLIANCE_FAILED == 'true'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const body = fs.readFileSync('pr-comment.md', 'utf8');
// Find and delete previous compliance check comments
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
for (const comment of comments.data) {
if (comment.body.includes('PR Compliance Check Failed') &&
comment.body.includes('automatically generated by the PR Compliance Check workflow')) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id
});
}
}
// Post new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
- name: Fail workflow if compliance failed
if: steps.final-status.outputs.COMPLIANCE_FAILED == 'true'
run: exit 1