-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (68 loc) · 2.28 KB
/
update-from-data.yml
File metadata and controls
72 lines (68 loc) · 2.28 KB
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
71
72
# File: .github/workflows/update-from-data.yml
name: Update from Data Repository
on:
repository_dispatch:
types: [update-from-data]
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout portfolio repository
uses: actions/checkout@v3
- name: Checkout data repository
uses: actions/checkout@v3
with:
repository: korenmiklos/remote-theme
path: temp-data
- name: Update files from data repository
run: |
# List of files and folders to manage
files_to_manage=(
"_courses"
"_data"
"_posts"
"_publications"
"blog"
"story.md"
"home-blog.md"
"search-blog.json"
"index.md"
# Add more files or folders as needed
)
# Remove existing items using git rm with force
for item in "${files_to_manage[@]}"; do
if [ -e "$item" ]; then
git rm -rf "$item"
echo "Removed $item from Git tracking"
fi
done
# Copy items from temp-data
for item in "${files_to_manage[@]}"; do
if [ -e "temp-data/$item" ]; then
cp -R "temp-data/$item" .
git add "$item"
echo "Copied and staged $item"
else
echo "Warning: $item not found in temp-data"
fi
done
# Special handling for home-blog.md and index.md
if [ -f "home-blog.md" ]; then
if [ -f "index.md" ]; then
# If both files exist, remove index.md and rename home-blog.md
git rm -f index.md
echo "Removed existing index.md"
fi
git mv home-blog.md index.md
echo "Renamed home-blog.md to index.md"
elif [ ! -f "index.md" ]; then
echo "Neither home-blog.md nor index.md found"
fi
- name: Remove temp-data folder
run: rm -rf temp-data
- name: Commit and push changes
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git commit -m "Update from data repository" || echo "No changes to commit"
git push