Skip to content

Commit

Permalink
Fixes lfai#37
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcube committed Oct 23, 2024
1 parent 7292a07 commit ce9a21e
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions .github/workflows/update_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,43 +79,25 @@ jobs:
- name: Add server to known hosts
run: ssh-keyscan -H $DEPLOY_HOST >> ~/.ssh/known_hosts

- name: Check for model changes on push
if: ${{ github.event_name == 'push' }}
run: |
git fetch origin main
git diff \
--name-only \
--diff-filter=AM origin/main...${{ github.sha }} | \
grep '^models/.*\.yml$' > models.txt || true
- name: Check for model changes on workflow_dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
- name: Check for model changes
run: |
git fetch origin ${{ github.ref_name }}
mkdir tmp
rsync -az \
--include="*.yml" \
--exclude="*" \
$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/models/ ./tmp/
find tmp/ -maxdepth 1 -type f | while read -r file; do
basefile=$(basename "$file")
if [ -f "models/$basefile" ]; then
git diff --name-only --no-index "$file" "models/$basefile" || true
fi
done > models.txt
git diff --name-only --no-index --diff-filter=AM tmp models > models.txt || true
rm -rf tmp
- name: Set model sync trigger
id: model_check
run: |
echo "sync=$([ -s models.txt ] && echo true || echo false)" >> $GITHUB_ENV
- name: Sync models
if: ${{ env.sync == 'true' }}
run: |
rsync -az \
--files-from=models.txt \
./ $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/
rsync -az --files-from=models.txt ./ $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/
ssh $DEPLOY_USER@$DEPLOY_HOST << EOF
cd $DEPLOY_PATH
./vendor/bin/drush scr scripts/sync_models.php
Expand Down

0 comments on commit ce9a21e

Please sign in to comment.