diff --git a/.github/workflows/validate_robopages.yml b/.github/workflows/validate_robopages.yml index c38e59f..fc70294 100644 --- a/.github/workflows/validate_robopages.yml +++ b/.github/workflows/validate_robopages.yml @@ -27,11 +27,11 @@ jobs: - name: Validate Contribution Files id: robopages-validation - continue-on-error: true run: | validate_file() { local file="$1" local tmp_file="/tmp/$(basename $file)" + local validation_status=0 if [[ ! "$file" =~ ^([a-zA-Z0-9_\-]+/)*[a-zA-Z0-9_\-]+\.yml$ ]]; then echo "Invalid file path characters: $file" @@ -54,18 +54,22 @@ jobs: docker pull dreadnode/robopages:latest - # Run validation with Docker socket mounted using temp file + # Run validation and capture the exit status docker run --rm \ -v $(pwd):/workspace \ -v /var/run/docker.sock:/var/run/docker.sock \ -v "$tmp_file:/workspace/$(basename $file)" \ -w /workspace \ --privileged \ - dreadnode/robopages:latest validate --path "$(basename $file)" --skip-docker + dreadnode/robopages:latest validate --path "$(basename $file)" --skip-docker || validation_status=$? rm "$tmp_file" + return $validation_status } + # Initialize overall status + overall_status=0 + # Get changed files using GitHub's provided variables changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | \ grep '\.yml$' | grep -v '^.github/' || true) @@ -73,15 +77,22 @@ jobs: # Validate each changed file for file in $changed_files; do echo "Validating $file..." - validate_file "$file" || exit 1 + if ! validate_file "$file"; then + overall_status=1 + echo "::error::Validation failed for $file" + fi done + exit $overall_status + - name: Post validation status if: always() uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #7.0.1 with: script: | - const validation_status = '${{ steps.robopages-validation.outcome }}' === 'success' ? '✅ Validation successful' : '❌ Validation failed'; + const validation_status = process.env.STATE_validation === '0' + ? '✅ Validation successful' + : '❌ Validation failed'; const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; const timestamp = new Date().toISOString(); const body = [ @@ -91,17 +102,16 @@ jobs: '', 'Please ensure your contribution follows the required format.', '', - `🔍 [View Full Validation Details](${runUrl})`, + `[View Full Validation Details](${runUrl})`, '', '---', `Run ID: \`${process.env.GITHUB_RUN_ID}\``, `Workflow: ${process.env.GITHUB_WORKFLOW}` ].join('\n'); - github.rest.pulls.createReview({ + github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: context.issue.number, - body: body, - event: 'COMMENT' + issue_number: context.issue.number, + body: body }); \ No newline at end of file