-
Notifications
You must be signed in to change notification settings - Fork 3
66 lines (54 loc) · 2.34 KB
/
check_if_new_model_added.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
name: Check for new model directories in views_pipeline/models
on:
push:
branches:
- create_pgm_catalog_01
- main
workflow_dispatch:
jobs:
check-new-folder:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check for new directories and generate catalog if models directory has changed
run: |
git status
# List all directories currently in the views_pipeline/models folder
current_dirs=$(find models -type d -maxdepth 1)
echo $current_dirs
# Fetch the previous commit from the main branch to compare
parent_commit=$(git rev-parse HEAD~1)
echo $parent_commit
git checkout 7fdf35d1e250f3270936a97502613c0b5d013f5a
# List directories from the previous commit
previous_dirs=$(find models -type d -maxdepth 1)
echo $previous_dirs
# Compare the directories
new_dirs=$(comm -13 <(echo "$previous_dirs" | sort) <(echo "$current_dirs" | sort))
echo "New folders detected in views_pipeline/models: $new_dirs"
removed_dirs=$(comm -23 <(echo "$previous_dirs" | sort) <(echo "$current_dirs" | sort))
echo "Removed folders detected in views_pipeline/models: $removed_dirs"
git checkout create_pgm_catalog_01
git status
# generate catalog if models directory has changed
ls -la
echo $new_dirs
echo $removed_dirs
if [ -n "$new_dirs" ] || [ -n "$removed_dirs" ]; then
python documentation/catalogs/generate_model_catalog.py
echo "Model catalog is updated."
else
echo "No new or removed folders detected."
fi
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Commit and Push Changes
run: |
git add documentation/catalogs/cm_model_catalog.md documentation/catalogs/pgm_model_catalog.md
git commit -m "Automated changes by GitHub Actions" || echo "Nothing to commit"
git push https://${{ secrets.VIEWS_PIPELINE_ACCESS_TOKEN }}:[email protected]/prio-data/views_pipeline.git