This repository has been archived by the owner on Jan 14, 2025. It is now read-only.
Daily Data Update #6
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: Daily Data Update | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
update_data: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install Dependencies | |
run: | | |
pip install bonbast jdatetime | |
- name: Run get_next.py and aggregator.py | |
run: | | |
while true | |
do | |
yesterday=$(date -d "yesterday" +%Y/%m/%d) | |
if [ -f "gregorian/$yesterday" ]; then | |
break | |
fi | |
python get_next.py | |
done | |
python aggregator.py | |
- name: Check if there are any changes | |
id: verify_diff | |
run: | | |
git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT | |
- name: Commit and Push Changes | |
if: steps.verify_diff.outputs.changed == 'true' | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add gregorian/* jalali/* | |
git commit -m "Update data - $(date +'%Y/%m/%d')" | |
git push | |
- name: Generate artifacts | |
run: | | |
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
echo "RELEASE_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
python artifact_generator.py | |
- name: Upload result as release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "artifact/*" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ env.TAG_NAME }} | |
name: ${{ env.RELEASE_NAME }} | |
- uses: dev-drprasad/delete-older-releases@v0.3.2 | |
with: | |
keep_latest: 10 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |