-
-
Notifications
You must be signed in to change notification settings - Fork 32
71 lines (61 loc) · 2.27 KB
/
_detect_changes.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Reusable detect changes workflow
on:
workflow_call:
inputs:
backend_directories:
description: Backend directories separated by spaces
required: false
type: string
default: ''
frontend_directories:
description: Frontend directories separated by spaces
required: false
type: string
default: ''
ubuntu_version:
description: Ubuntu version to use
type: string
default: latest
required: false
outputs:
backend:
description: Number of files changed in backend
value: ${{ jobs.detect-changes.outputs.backend }}
frontend:
description: Number of files changed in frontend
value: ${{ jobs.detect-changes.outputs.frontend }}
jobs:
detect-changes:
name: Detect changes
runs-on: ubuntu-${{ inputs.ubuntu_version }}
outputs:
backend: ${{steps.diff_check_backend.outputs.backend}}
frontend: ${{steps.diff_check_frontend.outputs.frontend}}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- uses: actions/checkout@v4
with:
clean: false
- name: Generate summary
if: ${{inputs.backend_directories != ''}} | ${{inputs.frontend_directories != ''}}
run: |
echo "### Detect Changes summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
- name: Generate diffs for backend
if: ${{inputs.backend_directories != ''}}
id: diff_check_backend
run: |
BACKEND_CHANGES=$(git diff --compact-summary origin/${{ github.base_ref }} -- ${{ inputs.backend_directories }} | head -n -1 | wc -l)
echo "backend=$BACKEND_CHANGES" >> $GITHUB_OUTPUT
echo "Backend Changes: $BACKEND_CHANGES" >> $GITHUB_STEP_SUMMARY
echo "backend $BACKEND_CHANGES"
- name: Generate diffs for frontend
if: ${{inputs.frontend_directories != ''}}
id: diff_check_frontend
run: |
FRONTEND_CHANGES=$(git diff --compact-summary origin/${{ github.base_ref }} -- ${{ inputs.frontend_directories }} | head -n -1 | wc -l)
echo "frontend=$FRONTEND_CHANGES" >> $GITHUB_OUTPUT
echo "Frontend Changes: $FRONTEND_CHANGES" >> $GITHUB_STEP_SUMMARY
echo "frontend $FRONTEND_CHANGES"