Update upload time #2
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: Update upload time | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 * * * *' | |
jobs: | |
build: | |
name: Update upload time | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main branch | |
uses: actions/checkout@v4 | |
- name: Checkout data branch | |
uses: actions/checkout@v4 | |
with: | |
ref: data | |
path: data | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11.5' | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Run black | |
run: black . | |
- name: Update data and build | |
env: | |
PROXY_URL: ${{ secrets.PROXY_URL }} | |
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} | |
run: python main.py | |
- name: Push data changes | |
run: | | |
cd data | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
if [ -n "$(git status --porcelain)" ]; then | |
git add . | |
git commit -m "Update database.sqlite3" | |
git push | |
else | |
echo "No changes to commit" | |
fi | |
cd .. | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Move build files to repo folder | |
run: rsync -a --delete --exclude .git --exclude .nojekyll --exclude index.html build/ gh-pages/ | |
- name: Push gh-pages changes | |
run: | | |
cd gh-pages | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
if [ -n "$(git status --porcelain)" ]; then | |
git add . | |
git commit -m "Update upload time" | |
git push | |
else | |
echo "No changes to commit" | |
fi |