feat(deploy): add vocab course change detection and sync step
Some checks failed
Deploy to production / deploy (push) Failing after 4m12s
Some checks failed
Deploy to production / deploy (push) Failing after 4m12s
- Implemented a new workflow step to detect changes in vocab course files and conditionally sync content. - Added a script to check for specific changes in the repository and trigger the sync process if necessary. - Introduced a new npm script for syncing vocab course content in the backend package.json.
This commit is contained in:
@@ -10,6 +10,33 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Detect vocab course changes
|
||||
id: vocab_course_changes
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
BASE="${{ gitea.event.before }}"
|
||||
HEAD="${{ gitea.sha }}"
|
||||
|
||||
if [ -z "$BASE" ] || [[ "$BASE" =~ ^0+$ ]] || ! git cat-file -e "$BASE^{commit}" 2>/dev/null; then
|
||||
BASE="HEAD~1"
|
||||
fi
|
||||
|
||||
git diff --name-only "$BASE" "$HEAD" > changed-files.txt
|
||||
cat changed-files.txt
|
||||
|
||||
if grep -E '^(backend/scripts/.*(bisaya|course|didactics|vocab)|backend/sql/.*vocab|backend/migrations/.*vocab|docs/.*(COURSE|VOCAB|BISAYA|GERMAN_FOR_BISAYA))' changed-files.txt; then
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Prepare SSH
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
@@ -31,4 +58,12 @@ jobs:
|
||||
ssh -i ~/.ssh/id_ed25519 \
|
||||
-p "${{ secrets.PROD_PORT }}" \
|
||||
"${{ secrets.PROD_USER }}@${{ secrets.PROD_HOST }}" \
|
||||
"/home/tsschulz/deploy-yourpart-bluegreen.sh"
|
||||
"/home/tsschulz/deploy-yourpart-bluegreen.sh"
|
||||
|
||||
- name: Sync vocab course content
|
||||
if: steps.vocab_course_changes.outputs.changed == 'true'
|
||||
run: |
|
||||
ssh -i ~/.ssh/id_ed25519 \
|
||||
-p "${{ secrets.PROD_PORT }}" \
|
||||
"${{ secrets.PROD_USER }}@${{ secrets.PROD_HOST }}" \
|
||||
"cd /opt/yourpart && npm --prefix backend run sync:vocab-courses"
|
||||
|
||||
Reference in New Issue
Block a user