This repository has been archived on 2023-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
dogstats/.gitea/workflows/autoupdate.yml

46 lines
1.5 KiB
YAML
Raw Normal View History

2023-12-22 21:33:07 +01:00
on:
schedule:
2023-12-22 21:41:21 +01:00
- cron: '0 3 * * 0,1,6' # at 1:01am on Friday, Saturday and Sunday
2023-12-12 20:47:37 +01:00
2023-12-12 22:27:49 +01:00
# on: [push]
2023-12-12 20:47:37 +01:00
jobs:
update_database:
2023-12-12 21:22:50 +01:00
runs-on: ubuntu-latest
2023-12-12 20:47:37 +01:00
steps:
- name: All tools we need
2023-12-12 21:36:06 +01:00
run: apt update && apt install -y default-jre git php php-dom php-curl php-sqlite3
2023-12-12 20:47:37 +01:00
- name: Checkout
uses: actions/checkout@v4
- name: run crawler
run: |
cd crawler
2023-12-22 21:33:07 +01:00
php crawler.php
git config --global user.email "gitea@haschek.at"
git config --global user.name "Gitea"
2023-12-23 16:09:46 +01:00
git add data.db
2023-12-22 21:33:07 +01:00
git commit -m "update database"
git push
2023-12-22 22:09:04 +01:00
- name: Configure SSH
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/staging.key
chmod 600 ~/.ssh/staging.key
- name: Run git pull on Server
run: |
ssh -i ~/.ssh/staging.key -o StrictHostKeyChecking=no -p 22 -o UserKnownHostsFile=/dev/null ${{ secrets.SSH_WEBSERVER_IP }} "cd /var/www/dogstats/ && git pull"
- name: Prepare
id: prep
run: |
SHORTREF=${GITHUB_SHA::10}
# Set output parameters.
echo ::set-output name=shortref::${SHORTREF}
- name: Updating version
run: |
ssh -i ~/.ssh/staging.key -o StrictHostKeyChecking=no -p 22 -o UserKnownHostsFile=/dev/null ${{ secrets.SSH_WEBSERVER_IP }} "echo v${{ steps.prep.outputs.shortref }} > /var/www/dogstats/web/version.txt"
2023-12-22 21:33:07 +01:00