Skip to content

Check last update time #274

Check last update time

Check last update time #274

name: Check last update time
on:
schedule:
- cron: "0 17 * * *" # noon EST
workflow_dispatch:
permissions:
contents: read
jobs:
CheckLastUpdateTime:
runs-on: ubuntu-latest
steps:
- name: Check last commit timestamp remotely
id: check-commit-timestamp
run: |
REPO_URL="https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/dandi/backup-status.git"
LAST_COMMIT_SHA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/dandi/backup-status/branches/main" | jq -r '.commit.sha')
LAST_COMMIT_DATE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/dandi/backup-status/commits/$LAST_COMMIT_SHA" | jq -r '.commit.committer.date')
LAST_COMMIT_TIMESTAMP=$(date -d "$LAST_COMMIT_DATE" +%s)
CURRENT_TIMESTAMP=$(date +%s)
THREE_DAYS_AGO=$(($CURRENT_TIMESTAMP - 3*24*60*60))
echo "Last commit timestamp: $LAST_COMMIT_TIMESTAMP"
echo "Three days ago timestamp: $THREE_DAYS_AGO"
if [ $LAST_COMMIT_TIMESTAMP -ge $THREE_DAYS_AGO ]; then
echo "The last commit was within the last 3 days."
else
echo "The last commit was more than 3 days ago."
exit 1
fi
- name: Success message
if: success()
run: echo "Disk space on Engaging partitions is within acceptable range."
NotifyOnFailure:
runs-on: ubuntu-latest
needs: [ CheckLastUpdateTime ]
if: ${{ always() && needs.CheckLastUpdateTime.result == 'failure' }}
steps:
- uses: dawidd6/action-send-mail@v17
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: DANDI backup has not been updated
to: cody.c.baker.phd@gmail.com # Add more with comma separation (no spaces)
from: Backup Status <backup-status@users.noreply.github.com>
body: "DANDI backup status has not been updated within the last 3 days: https://github.com/dandi/backup-status"