add theo lecture #231
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: Generate Anki Packages | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- 'README.md' | |
- 'LICENSE' | |
workflow_dispatch: | |
jobs: | |
build: | |
if: github.actor != 'AnkiTUM-Bot' | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.BOT_GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- name: Set up Python 3.x environment | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Setup Git | |
run: | | |
git config --global user.name "AnkiTUM-Bot" | |
git config --global user.email ${{ secrets.BOT_GITHUB_EMAIL }} | |
- name: Set up private key | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
run: | | |
mkdir -p $HOME/.ssh | |
echo "$SSH_PRIVATE_KEY" | base64 --decode > $HOME/.ssh/id_ed25519 | |
chmod 600 $HOME/.ssh/id_ed25519 | |
ssh-keyscan -H ${{ secrets.MIRROR_IP }} >> $HOME/.ssh/known_hosts | |
- name: Run ID Fixup Script | |
run: | | |
pip install -r .github/workflows/requirements.txt --user | |
python3 .github/workflows/id_fixup.py ./ | |
git add . | |
# Check if there are any changes | |
if git diff --staged --quiet; then | |
echo "No changes to commit" | |
else | |
git commit -m "AnkiBot: Automatically added missing IDs" | |
git push | |
fi | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends zip git python3-dev | |
python -m venv venv | |
source venv/bin/activate | |
git clone https://github.com/hmelder/AnkiTUM-Runtime | |
pip install -r AnkiTUM-Runtime/requirements.txt | |
pip install ./AnkiTUM-Runtime | |
- name: Generate Anki packages and compress | |
run: | | |
source venv/bin/activate | |
./build.sh | |
- name: Upload via SFTP | |
env: | |
MIRROR_IP: ${{ secrets.MIRROR_IP }} | |
MIRROR_USER: ${{ secrets.MIRROR_USER }} | |
run: | | |
sftp -i $HOME/.ssh/id_rsa $MIRROR_USER@$MIRROR_IP:/var/www/html/anki-decks <<< $'put -r build/*.zip' |