Files
raid-callouts/.github/workflows/deploy.yaml
Gabriella Agathon 45401614d5
All checks were successful
Test Helper Module / test (3.11.5) (push) Successful in 29s
Update workflows
2026-02-19 22:05:40 -07:00

105 lines
3.6 KiB
YAML

name: test and deploy
on:
push:
branches: [ main ]
# Set up for manual running, just in case. Can be removed later
workflow_dispatch:
jobs:
# test locally on the runner, using miniconda
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11.5]
steps:
- uses: https://github.com/actions/checkout@v4.1.1
- name: Setup Poetry
uses: Gr1N/setup-poetry@v9
- name: Install dependencies
shell: bash -l {0}
run: |
poetry instsall
- name: add database.ini
shell: bash -l {0}
run: |
cd $GITHUB_WORKSPACE/
touch database.ini
echo "${{ secrets.DATABASE_INI }}" >> xiv-database.ini
- name: Run tests
shell: bash -l {0}
run: |
conda activate test-helper-module
poetry run python -m pytest src/py/db_helper_tests.py
# Checkout the repo, add the dependency files, push to host, build + run (via docker compose up)
push-and-build:
runs-on: ubuntu-latest
needs: "test"
steps:
- uses: https://github.com/actions/checkout@v4
- uses: https://github.com/shimataro/ssh-key-action@v2.7.0
with:
key: ${{ secrets.HOST_PRIVATEKEY }}
known_hosts: ${{ secrets.SSH_HOST }}
- name: install rsync
run: |
apt-get update
apt-get install rsync -y
- name: add xiv database.ini
run: |
cd $GITHUB_WORKSPACE/
touch database.ini
echo "${{ secrets.DATABASE_INI }}" >> xiv-database.ini
- name: add ffxiv discord token
run: |
cd $GITHUB_WORKSPACE/
echo "${{ secrets.DISCORD_TOKEN }}" >> xiv-discord.token
- name: add dnd database.ini
run: |
cd $GITHUB_WORKSPACE/
touch database.ini
echo "${{ secrets.DND_DATABASE_INI }}" >> dnd-database.ini
- name: add dnd discord token
run: |
cd $GITHUB_WORKSPACE/
echo "${{ secrets.DND_DISCORD_TOKEN }}" >> dnd-discord.token
- name: add known hosts to runner
run: |
ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
# This is set to continue even w/ error, because there is a chance that docker compose down doesn't completely work
- name: remove old image from host
run: |
ssh -v ${{ secrets.HOST_USER }}@${{ secrets.SSH_HOST }} "cd /home/${{ secrets.HOST_USER }}/runner/raid-callouts && docker compose down"
continue-on-error: true
- name: clean build directory on host
run: |
ssh ${{ secrets.HOST_USER }}@${{ secrets.SSH_HOST }} "rm -rdf /home/${{ secrets.HOST_USER }}/runner/raid-callouts"
continue-on-error: true
- name: deploy /w rsync to host
run: |
sudo rsync -avz $GITHUB_WORKSPACE ${{ secrets.HOST_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.HOST_USER }}/runner/
- name: build docker image on host + run it
run: |
ssh ${{ secrets.HOST_USER }}@${{ secrets.SSH_HOST }} "cd /home/${{ secrets.HOST_USER }}/runner/raid-callouts && docker compose up --build -d"