Update monitoring workflow #83
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: KVFinder-web service job submission statistics | |
on: | |
schedule: | |
- cron: '0 0 1 * *' | |
push: | |
branches: [master] | |
workflow_dispatch: | |
jobs: | |
data: | |
name: Get job submission data | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get data from the server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
script: | | |
echo ${{ secrets.PASSWORD }} | sudo -S su - -c "cat 01_2023_to_12_2024.txt > usage.txt && ls /var/lib/containers/storage/volumes/kvfinder_web_service_kvfinder-jobs/_data -lhrt --time-style=long-iso >> /home/${{ secrets.USERNAME }}/usage.txt" | |
scp-copy: | |
name: Copy job submission data | |
runs-on: ubuntu-latest | |
needs: [data] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Copy job submission data | |
uses: nicklasfrahm/scp-action@main | |
with: | |
direction: download | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
insecure_password: ${{ secrets.PASSWORD }} | |
insecure_ignore_fingerprint: true | |
source: /home/${{ secrets.USERNAME }}/usage.txt | |
target: ./usage.txt | |
- name: Run python script to produce usage plots | |
run: | | |
pip install -r .github/workflows/requirements.txt | |
python3 .github/workflows/statistics.py | |
mkdir usage | |
mv usage.txt *.png usage/ | |
- name: Upload job submission data | |
uses: actions/upload-artifact@v4 | |
with: | |
name: usage | |
path: usage | |
- name: Send email | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: smtp.gmail.com | |
server_port: 465 | |
secure: true | |
username: ${{ secrets.EMAIL_USERNAME }} | |
password: ${{ secrets.EMAIL_PASSWORD }} | |
subject: ${{ github.repository }} ${{ github.job }} is ${{ job.status }} | |
body: Build job of ${{github.repository}} completed successfully! | |
to: ${{ secrets.EMAIL }} | |
from: ${{ secrets.EMAIL }} | |
attachments: ./usage/* |