Update monitoring workflow #89
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: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Get current date | ||
id: date | ||
run: echo "::set-output name=date::$(date +'%Y-%m')" | ||
- 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 /home/${{ secrets.USERNAME }}/01_2023_to_12_2024.txt > /home/${{ secrets.USERNAME }}/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] | ||
- 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 ${{ steps.date.outputs.date }} | ||
mv usage.txt *.png ${{ steps.date.outputs.date }} | ||
tar -czvf ${{ steps.date.outputs.date }}.tar.gz ${{ steps.date.outputs.date }} | ||
- name: Send job submission data to the server | ||
uses: nicklasfrahm/scp-action@main | ||
with: | ||
direction: upload | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
insecure_password: ${{ secrets.PASSWORD }} | ||
insecure_ignore_fingerprint: true | ||
source: ${{ steps.date.outputs.date }}.tar.gz | ||
target: ./statistics/${{ steps.date.outputs.date }}.tar.gz | ||
- name: Upload job submission data | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ steps.date.outputs.date }} | ||
path: ${{ steps.date.outputs.date }} | ||
- name: Clean up | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
echo ${{ secrets.PASSWORD }} | sudo -S su - -c "rm /home/${{ secrets.USERNAME }}/usage.txt" |