Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions workflow-templates/eslint.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "ESLint Check",
"description": "This template runs ESLint to check for linting errors in the project.",
"iconName": "octicon-lint",
"categories": [
"JavaScript",
"TypeScript"
],
"filePatterns": [
"src/**/*.js",
"src/**/*.ts"
]
}
46 changes: 46 additions & 0 deletions workflow-templates/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Linting # This can include other types of linting later on

on:
push:
branches:
- main

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add main, master and develop branches

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay i will add

- master
- develop
pull_request:
branches:
- main
- master
- develop

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: npm install

# Get the list of changed files in the PR
- name: Get list of changed files
id: changed-files
run: |
git fetch origin ${{ github.base_ref }}
git diff --name-only origin/${{ github.base_ref }}...${{ github.sha }} > changed_files.txt
cat changed_files.txt


# Run linter only on changed JavaScript/TypeScript files
- name: Run linter on changed JavaScript/TypeScript files
run: |
CHANGED_FILES=$(cat changed_files.txt | grep '\.js\|\.jsx\|\.ts\|\.tsx' || true)
if [ -n "$CHANGED_FILES" ]; then
echo "Linting the following files:"
echo "$CHANGED_FILES"
npx eslint $CHANGED_FILES
else
echo "No JavaScript/TypeScript files to lint."
fi
13 changes: 13 additions & 0 deletions workflow-templates/npm-audit.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "NPM Audit",
"description": "This template runs npm audit to check for vulnerabilities in dependencies.",
"iconName": "octicon-security",
"categories": [
"Security",
"JavaScript"
],
"filePatterns": [
"package.json$",
"package-lock.json$"
]
}
30 changes: 30 additions & 0 deletions workflow-templates/npm-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: npm Audit

on:
pull_request:
paths:
- 'package.json'
- 'package-lock.json'

jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm install

- name: Run npm audit (Allow skipping unfixed vulnerabilities)
run: npm audit
continue-on-error: true # Allow PR to pass even if vulnerabilities are found

- name: Check for fixable vulnerabilities
run: |
npm audit --json > audit-report.json
FIXABLE=$(grep -c '"fixAvailable": true' audit-report.json)
if [ "$FIXABLE" -gt 0 ]; then
echo "$FIXABLE fixable vulnerabilities found."
exit 1 # Block PR if there are fixable vulnerabilities
else
echo "No fixable vulnerabilities found."
fi