Skip to content

Commit

Permalink
Merge pull request #24 from dreadnode/ads/eng-262-fix-fix-gh-validati…
Browse files Browse the repository at this point in the history
…on-workflow-for-robopages-on-skip

fix: try fix the workflow validation with shell
  • Loading branch information
evilsocket authored Nov 26, 2024
2 parents 251364a + d4e06e0 commit dffac33
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/validate_robopages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
run: |
validate_file() {
local file="$1"
local tmp_file="/tmp/$(basename $file)"
if [[ ! "$file" =~ ^([a-zA-Z0-9_\-]+/)*[a-zA-Z0-9_\-]+\.yml$ ]]; then
echo "Invalid file path characters: $file"
Expand All @@ -42,16 +43,29 @@ jobs:
return 1
fi
# Create copy and inject categories if missing
cp "$file" "$tmp_file"
if ! grep -q "categories:" "$tmp_file"; then
# Extract categories from path
categories=$(dirname "$file" | tr '/' '\n' | awk 'NF' | sed 's/^/ - /')
# Inject categories into YAML
echo -e "\ncategories:\n$categories" >> "$tmp_file"
fi
docker pull dreadnode/robopages:latest
# Run validation with Docker socket mounted and skip categories validation
# Run validation with Docker socket mounted using temp file
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 "$(printf '%q' "$file")" --skip-docker
dreadnode/robopages:latest validate --path "$(basename $file)" --skip-docker
rm "$tmp_file"
}
# 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)
Expand Down Expand Up @@ -90,4 +104,4 @@ jobs:
pull_number: context.issue.number,
body: body,
event: 'COMMENT'
});
});

0 comments on commit dffac33

Please sign in to comment.