Skip to content

Commit

Permalink
Merge pull request #21 from studiorack/feature/validate-changed-files
Browse files Browse the repository at this point in the history
Feature/validate changed files
Fixes #17
  • Loading branch information
kmturley authored Sep 19, 2024
2 parents e016542 + 7893f3b commit f3adb99
Show file tree
Hide file tree
Showing 7 changed files with 686 additions and 110 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Validate

on:
pull_request:

jobs:
validate:
name: Validate code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install
run: |
npm ci
- name: Build
run: |
npm run build
- name: Changed files
id: changed-files
uses: tj-actions/changed-files@v45

- name: Validate changed files
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
for file in ${CHANGED_FILES}; do
node ./build/validate.js $file
done
echo 'Downloads:'
ls ./downloads/
- name: VirusTotal Scan
id: virustotal
uses: crazy-max/ghaction-virustotal@v4
with:
vt_api_key: ${{ secrets.VT_API_KEY }}
request_rate: 4
files: ./downloads/*

- name: VirusTotal Report
uses: actions/github-script@v7
with:
script: |
const analysis = '${{steps.virustotal.outputs.analysis}}';
if (!analysis) return;
let output = 'VirusTotal Report:\n';
let lines = analysis.split(',');
for (let line of lines) {
output += '- [' + line.replace('./downloads/', '').replace('=https', '](https') + ')\n';
}
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
});
const existingComment = comments.find(comment => comment.user.id === 41898282);
if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: output
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
body: output
});
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ coverage

# Transpiled files
build/
downloads/
out/

# VS Code
Expand All @@ -27,4 +28,4 @@ out/
.eslintcache

# Misc
.DS_Store
.DS_Store
Loading

0 comments on commit f3adb99

Please sign in to comment.