Skip to content

update-from-data

update-from-data #50

# 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"
"_datasets"
"_events"
"_software"
"_publications"
"assets"
"software.md"
"datasets.md"
"events.md"
"home-courses-2.md"
"search-courses.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-courses2.md and index.md
if [ -f "home-courses-2.md" ]; then
if [ -f "index.md" ]; then
# If both files exist, remove index.md and rename home-courses2.md
git rm -f index.md
echo "Removed existing index.md"
fi
git mv home-courses-2.md index.md
echo "Renamed home-courses2.md to index.md"
elif [ ! -f "index.md" ]; then
echo "Neither home-courses2.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 add .
git commit -m "Update from data repository" || echo "No changes to commit"
git push