Skip to content

Commit

Permalink
Merge pull request #28 from dreadnode/ads/eng-323-bug-regression-in-r…
Browse files Browse the repository at this point in the history
…obopages-workflow-validation-failures

fix: fix regression in continue on error
  • Loading branch information
evilsocket authored Nov 29, 2024
2 parents dffac33 + 2e01869 commit 5965ed1
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/validate_robopages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -54,34 +54,45 @@ 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)
# 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 = [
Expand All @@ -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
});

0 comments on commit 5965ed1

Please sign in to comment.