Sync Questions and Prüfstellen #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync Questions and Prüfstellen | |
on: | |
schedule: | |
- cron: "0 0 */15 * *" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
scrap_questions_and_pruefstellen: | |
name: Sync Questions and Prüfstellen | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "latest" | |
- name: Install dependencies | |
run: | | |
cd src/scrap | |
npm install | |
- name: Sync | |
run: | | |
cd src/scrap | |
npm run prod | |
env: | |
TRANSLATOR_KEY: ${{ secrets.TRANSLATOR_KEY }} | |
AI_URL: ${{ secrets.AI_URL }} | |
AI_KEY: ${{ secrets.AI_KEY }} | |
- name: Move | |
run: | | |
cp src/scrap/data/question.json src/app/web/data/question.json | |
cp src/scrap/data/prüfstellen.json src/app/web/data/prüfstellen.json | |
- name: Check for changes | |
id: git_check | |
run: | | |
git add src/app/web/data/question.json | |
git add src/app/web/data/prüfstellen.json | |
if git diff --cached --quiet; then | |
echo "No changes detected" | |
echo "changed=false" >> $GITHUB_ENV | |
else | |
echo "Changes detected" | |
echo "changed=true" >> $GITHUB_ENV | |
fi | |
- name: Bump version if changes detected | |
if: env.changed == 'true' | |
working-directory: src/app/web | |
run: | | |
npm version minor --no-git-tag-version | |
- name: Commit and Push Changes | |
if: env.changed == 'true' | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git add . | |
git commit -m "Sync questions & bump version" | |
git push |