-
Notifications
You must be signed in to change notification settings - Fork 109
50 lines (42 loc) · 1.78 KB
/
run-dangerjs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Run DangerJS
on:
pull_request:
branches: [main]
types: [edited, labeled, opened, pushed, reopened, synchronize]
jobs:
danger-front:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
# Optimize compute resources by verifying changes in SQL models files and front/pages/api/v1/* before running Danger.
- name: Check for file changes
id: file_changes
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/main:refs/remotes/origin/main
echo "Checking for changed files..."
CHANGED_FILES=$(git diff --name-only origin/main ${{ github.sha }} -- 'front/lib/models/' 'front/lib/resources/storage/models/' 'connectors/src/lib/models/' 'connectors/src/resources/storage/models/' 'front/pages/api/v1/')
if [ -n "$CHANGED_FILES" ]; then
echo "Changed files found:"
echo "$CHANGED_FILES"
echo "run_danger=true" >> $GITHUB_OUTPUT
echo "::warning ::Files in 'front/lib/models/', 'connectors/src/lib/models/', or 'front/pages/api/v1/' have been modified."
else
echo "No changed files found."
echo "run_danger=false" >> $GITHUB_OUTPUT
fi
- name: Set up Node.js
if: ${{ steps.file_changes.outputs.run_danger == 'true' }}
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install dependencies
if: ${{ steps.file_changes.outputs.run_danger == 'true' }}
run: cd front && npm install
- name: Run Danger for front
if: ${{ steps.file_changes.outputs.run_danger == 'true' }}
run: cd front && npx danger ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}